This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Linux / UNIX and the fly likes NoClassDefFoundError Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "NoClassDefFoundError" Watch "NoClassDefFoundError" New topic
Author

NoClassDefFoundError

Abhishek Dhama
Greenhorn

Joined: Nov 17, 2003
Posts: 12
Hi all,
I am a newbie on linux.
I wrote this test program to run on JDK I installed. It compiled fine but when I tried to run it walked out with
<error message>
Exception in thread "main" java.lang.NoClassDefFoundError: Test
</error message>
Now yes I did type "java Test" and I did set CLASSPATH and JAVA_HOME variables right.
I am running Redhat 9.0 .
JDK installed is 1.4
I not able to figure out where I went wrong
I am not attaching code snipet coz it isnt doing much simple Hello world types.
Thanks in advance
/abhishek
Nart
Ranch Hand

Joined: May 28, 2002
Posts: 95
Hello Abhishek,
Seems like your classpath doesnt point to the current directory. There is no need to set the classpath as an environment variable, its discouraged.
To quickly check if this is the problem try the following:
prompt> java -classpath . Test
This is the preferred method of setting the classpath. Basically, if your classpath is set for example in .bash_profile, and it doesnt include the current directory '.', then the default classpath when running the 'java' command which is the current directory, is ignored, and your Test class is therefore not found.
Check this: http://faq.javaranch.com/view?HowToSetTheClasspath
for general classpath info.
Nart
 
Consider Paul's rocket mass heater.
 
subject: NoClassDefFoundError