Discussion Locked

NoClassDefFound Error running Main

0 helpful
3 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I just downloaded Java 1.3.1 and successfully installed it on my Jaz drive (D:). I then successfully compiled 2 "Hello World" class files - TestGreeting.java and Greeting.java. They compiled okay. Every time I try to run it in DOS I get an error message indicating that main was unable to find the needed class files: NoClassDefFound error.

I have tried the following with no success:

Set classpath=.;d:\develop\java\files

Made sure that the name I specified with the java command was exactly correct:
"java TestGreeting"
Tried to run this with the files directory as my current directory with the classpath removed.

Verified that the class files exist in the files directory.

I saw another post that suggested thereis a Java bug that causes this error when you install and try to run from a directory other than C.

Can anyone help? I don't have much hair left to pull out.

Thanks.

3 replies

by basit_jafri

I must know what OS ur using but you should be carefull about ur classpath too
instead of ur statement try

set classpath=%classpath%;.;whatever

you should include all the exising class paths.

If the thing is not working, try moving the location of the file to C drive, it works there or some other location, you can better figure out the problem

BA

by netwell.inc

Shortly before I received this answer, I decided to download Java 1.3.1 again and restart from scratch. This solved the problem so therefore it's apparent that the first download was somehow defective and caused the problem. Thanks BA for your attempt to help and I'm sorry I didn't respond sooner. I'm new at Tech Republic and didn't understand the protocol.

TR

This discussion is closed to new replies.