• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NoClassDefFoundError

 
Abhishek Dhama
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 95
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic