• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Getting error in sample program

 
Lavesh saxena
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I am new & getting error in sample progam..

Error is "Exception in thread "main" java.lang.Noclassdeffounderror"..


My java code is belwo.

class Example {
public static void main(String args[])
{
System.out.println ("THis is Example.");
}
}

THanks in advance.

Lavesh...
 
Kieren Dixon
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The source code is fine. Check your environmental variables are Setup correctly
 
James Tharakan
Ranch Hand
Posts: 580
Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Double posts are NOT appreciated also here
 
Campbell Ritchie
Sheriff
Posts: 48382
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should make yourself a folder somewhere in home or My Documents or similar (not in Program Files) and put all your Java work there. If you open a command line, then write mkdir java, then cd java, and you are straight into your folder and can find everything.
Using the "dir" or "ls" commands allows you to see whether your .class file actually exists.

The error message suggests you have in fact set up your PATH correctly, so don't alter them. Did you get any compiler errors?

Don't set a system classpath at all at this stage. If you set a system classpath in the last 24 hours, you have done it wrongly. Have you installed any programs which might have set their own classpath? You may find it easiest to add .; to the beginning of the classpath.

And I have closed your duplicate post.
 
Lavesh saxena
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks below is worked well.

C:\ java Example
 
James Tharakan
Ranch Hand
Posts: 580
Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hope you understood WHY that worked.
Because when combined with pakage and import statement commands at the command prompt would be really confusing....
 
Lavesh saxena
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes i got it... i think this will not happen again...

thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic