Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Exception in thread "main" java.lang.NoClassDefFoundError

Status
Not open for further replies.

jain747

Technical User
Apr 22, 2003
17
US
I'm trying to run a java file on j2dk1.4 but I get the error Exception in thread "main" java.lang.NoClassDefFoundError: Fruit on Windows XP home edition OS. I'm reading up on the error and it states to edit the classpath, but I'm not sure exactly how to. The class file is in the same folder as the java file. Thanks in advance for the help.
 
Try the following:

Code:
java -cp .;C:\ fruit

This will set the classpath to C:\ and to your HOMEDRIVE.

If this does not your and you please provide the path to you class file.
 
The directory to the class file is C:\Documents and Settings\jain747\My Documents\NOTES\Java
I tried the command you gave me and a bit of the error I got is: Exception in thread "main" java.lang.NoClassDefFoundError: fruit (wrong name: Fruit)at java.lang.ClassLoader.defineClass0(Native Method)at java.lang.ClassLoader.defineClass(ClassLoader.java:502

thanks again
 
Ok...One more question... Can you make sure that the class name match the file name...for example...

public class Fruit

is the same as

Fruit.class

when you run the command java the filename has to be in the same case as the class name.

Hope this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top