aspose file tools*
The moose likes Beginning Java and the fly likes Getting error in sample program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Getting error in sample program" Watch "Getting error in sample program" New topic
Author

Getting error in sample program

Lavesh saxena
Greenhorn

Joined: Oct 11, 2008
Posts: 15
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

Joined: Jan 30, 2009
Posts: 27
The source code is fine. Check your environmental variables are Setup correctly
James Tharakan
Ranch Hand

Joined: Aug 29, 2008
Posts: 580

Double posts are NOT appreciated also here


SCJP 6
Why to worry about things in which we dont have control, Why to worry about things in which we have control ! !
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36575
    
  16
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

Joined: Oct 11, 2008
Posts: 15
Thanks below is worked well.

C:\ java Example
James Tharakan
Ranch Hand

Joined: Aug 29, 2008
Posts: 580

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

Joined: Oct 11, 2008
Posts: 15
yes i got it... i think this will not happen again...

thanks
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Getting error in sample program
 
Similar Threads
Doubt in if()
Difficulty in executing
Error during large batch insertion for preparedstatement (395 parameters)
Oreilly's Java & XML Book
System.out.println(null)