Win a copy of Soft Skills: The software developer's life manual this week in the Jobs Discussion forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Exception in thread "main" NoClassDefFoundError

 
Shraga van Shufel
Ranch Hand
Posts: 33
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
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
Shraga.
 
Leila Algarve
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try:
java Test
 
Shraga van Shufel
Ranch Hand
Posts: 33
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
10x it works fine
Stupid me
 
Francis Siu
Ranch Hand
Posts: 867
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Shraga
Firstly, please edit your code to following which I recommand

And then save the file named
Test.java
Do you compile the programme once before run it?
if no,please do the following
javac Test.java
then run the programme
java Test
oo...
If you do the above state and can not run it,
Please feel free to let me know
thanks
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic