File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Exception in thread Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Exception in thread "main" NoClassDefFoundError" Watch "Exception in thread "main" NoClassDefFoundError" New topic

Exception in thread "main" NoClassDefFoundError

Shraga van Shufel
Ranch Hand

Joined: Apr 20, 2003
Posts: 33
I think I am struggling with a known prob but I can't seems to figure it out.
I have a simple class and I am getting the above error when I try to run it from the command line.
when I try to run it from an IDE no problem.
public class Test {
public static void main(String [] args){
System.out.println("it works");
I set the classpath to the location of the class and also try to run the program using
# java -classpath . Test.class
if I echo the classpath I am getting to correct path
what am I doing wrong ?
thanks in advance
Leila Algarve

Joined: Apr 13, 2003
Posts: 2
java Test
Shraga van Shufel
Ranch Hand

Joined: Apr 20, 2003
Posts: 33
10x it works fine
Stupid me
Francis Siu
Ranch Hand

Joined: Jan 04, 2003
Posts: 867
hi Shraga
Firstly, please edit your code to following which I recommand

And then save the file named
Do you compile the programme once before run it?
if no,please do the following
then run the programme
java Test
If you do the above state and can not run it,
Please feel free to let me know

Francis Siu
I agree. Here's the link:
subject: Exception in thread "main" NoClassDefFoundError
jQuery in Action, 3rd edition