java exception: java.lang.NoClassDefFoundError
Hi,
I've just installed j2sdk, using the self extracting binary on linux (debian). The install process seemed to go fine, and everything appears to be there. I've got a REALLY basic hello world program: public class Hello { public static void main(String[] args) { System.out.println("Hello"); } } saved as Hello.java Compile it: $HOME/java_code> javac Hello.java no problems, but when I try to run it: $HOME/java_code> java Hello I get: Exception in thread "main" java.lang.NoClassDefFoundError: Hello I've tried setting the PATH, JAVA_HOME, and CLASS_PATH variables, but it doesn't seem to make any difference. I realise this question has been asked before, but most of the responses seemed to be: try setting your CLASS_PATH.... which hasn't helped. Can someone help me please? Kath. |
Make sure you're setting CLASSPATH, not CLASS_PATH, and make sure "." is in it:
export CLASSPATH=.:$CLASSPATH java Hello |
DOH!
Thanks... it works now. |
HI, I really need some help. I just installed LInux SuSE 9.1 and I cant get javac to work, it tells me the following
javac: command not found. Exacly how do I set the paths I see you people talking about? Please. Im really new to java and Have no idea whats going on with the JSDK. I downloaded the 1.4 sdk from sun and installed it without problems. I just dont know what to enter into the command to get my code to compile. Plz help, thanks. |
If i'm not mistaken, the installation of sun's jdk do not put the symlinks of the java executables (java, javac etc) into /usr/local/bin ( that's where you want it right?)
You'll have to create them yourself or add the bin directory of the sdk to your path. BTW, to see your PATH and CLASSPATH env variables just Code:
echo $PATH |
lol, thanks mirradric.
Basically what i did is downloaded the sdk from sun, version 1.4 installed it and thats about it :) Doing the echo i got the following results: sywlyn@sywlyn:~/Documents/projects marked/PersonalOrganizer> echo $PATH /home/sywlyn/bin:/home/sywlyn/bin/:/usr/local/bin:/usr/bin:/usr/X11R6/bin:/bin:/usr/games:/opt/gnome/bin:/opt/kde3/bin:/usr/lib/java/jre/bin when I tried to echo classpath nothing happend at all. Should I change anything? Add the them? should I go into the bin directory where javas sdk was installed and copy the contents "which includes javac" into /usr/local/bin ? I know when I installed my windows sdk I had to change variables, but I dont know how or where to change them in linux? |
anyone, plz?
|
to add something to your path, edit /etc/profile or equivalent and add something like
Code:
PATH=/path/to/sdk/bin:$PATH or you can create links in /usr/local/bin to the individual program/command that you want users to run. If you want the jre plugin in your web browser I think the instructions are there as well. |
oh...
I forgot that you have to Code:
export PATH |
thanks alot mirradric, it worked! :) thanks. I see unlike windows when it comiles it doesnt automaticly launch the application.
I do however get NoClasDefFound error now when I type in: java (classname) |
look somewhere towards the beginning of this thread....
sorry my concentration is slipping |
just in case people read this the wrong way; it was way past my bedtime.
Quote:
|
Quote:
|
All times are GMT -5. The time now is 10:20 PM. |