PDA

View Full Version : Java in 6.10



mcgooie
April 7th, 2007, 07:18 PM
Im trying to get a java compliler (Eclipse or JEdit) setup so that i can do my java work on a laptop with just ubuntu on it. I have installed the sun java files and both of these IDE's but still having problems after various attempts.

Could someone give me some advice/guides on what to do from a freshly installed 6.10 version and also how to compile and run the java programs in either Eclipse or Jedit?

Thank you very much :D

cobray
April 7th, 2007, 07:33 PM
I installed the sun-java5-* packages
and installed eclipse from their web site (not thru synaptic)
everything works really good.
I had problems running eclipse after installing it from the repository

you may need to do
sudo update-java-alternatives

mcgooie
April 7th, 2007, 08:05 PM
can you post links to what you downloaded from the eclipse site as im not 100% sure what i need to get?

thx

cobray
April 7th, 2007, 08:20 PM
goto www.eclipse.org
click the Download button
download the Eclipse SDK 3.2.2

I downloaded the tar file, and expanded it in my home directory
Then I added a custom launcher to the top panel
/home/dkilcy/eclipse/eclipse -Xmx512m

I am using Edgy 6.10 on amd64

mcgooie
April 7th, 2007, 08:23 PM
thanks mate im getting this now, can you tell me what the "Xmx512m" launch command does?

cobray
April 7th, 2007, 10:04 PM
-Xmx512m tells the java program it can allocate up to 512 megs of memory. The default is 64M.

cobray
April 7th, 2007, 10:22 PM
I just updated to java 6 just now and it is working also with Eclipse SDK 3.2.2

mcgooie
April 9th, 2007, 06:18 PM
just got a simple "Hello World" program to test out and when i compile in Eclipse and the terminal using javac + java i get the following message:


Exception in thread "main" java.lang.NoClassDefFoundError:

Any ideas?

phossal
April 9th, 2007, 07:08 PM
Post your source, and the commands you're using.

mcgooie
April 9th, 2007, 07:21 PM
test.java file



class test
{
public static void main(String args[])
{
System.out.println("Hello World!");
}

}

compile this using javac test.java

then i use java test

This is now working for me in the terminal but i still get the same error message in Eclipse. Is there something i have to configure in Eclipse that i dont know about?

phossal
April 9th, 2007, 08:51 PM
From the toolbar: Run -> Run -> Java Application -> "New Button" -> Run ... and it fails? Have you searched for your main class? The only trouble I can imagine is that a) you haven't set the compiler options correctly b) you've packaged your class incorrectly, or might need public.

Based on what you've posted, I can't tell you exactly what's wrong. There are little tweaks I make depending on how I've installed eclipse.

Ramses de Norre
April 9th, 2007, 10:57 PM
Your class must be public.

phossal
April 10th, 2007, 04:11 AM
Ramses, if you create project in eclipse, and name it "test", and then create a class within your project - even in the default package (against eclipse's recommendation) - you do not need to make the class public to execute it within eclipse. I tried.

aok
April 10th, 2007, 03:32 PM
just got a simple "Hello World" program to test out and when i compile in Eclipse and the terminal using javac + java i get the following message:


Exception in thread "main" java.lang.NoClassDefFoundError:

Any ideas?

I think you forgot to set your JAVA_HOME environment variable so the CLASSPATH didn't get set.

Assuming you installed the sun-java5-* packages, try putting this in your .bashrc (and re-log in):


export JAVA_HOME=/usr/lib/jvm/java-1.5.0-sun/

mcgooie
April 11th, 2007, 01:41 PM
thanks for that aok, can you tell me the path to the .bashrc file? i assume its a normal sudo gedit to open the file itself?

slavik
April 11th, 2007, 02:16 PM
.bashrc is in your home directory, no need for sudo. :)

mcgooie
April 11th, 2007, 02:57 PM
cheers, il try that after work today. Thanks for giving a noob all the help guys