jQuery in Action, 2nd edition*
The moose likes Beginning Java and the fly likes The infamous Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "The infamous "NoClassDefFoundError"" Watch "The infamous "NoClassDefFoundError"" New topic
Author

The infamous "NoClassDefFoundError"

Jason Greenwood
Greenhorn

Joined: Apr 25, 2006
Posts: 3
OK. Yesterday, I read through all the threads on this topic, and got my work comp compiling and running without a problem. This morning I'm trying it at home, and I'm still getting the error

"Exception in thread "main" java.lang.NoClassDefFoundError: Test

I've got my CLASSPATH set to the following

.;C:\Program Files\Java\j2re1.4.2_05\lib\ext\QTJava.zip; C:\java stuff; C:\Program Files\Java\jdk1.5.0_06\bin

I can compile with javac just fine, but running the Test.class with the java command doesn't work.

What silly, simple thing am I missing? I'm not typing java Test.class, I've got my capitalization correct, I've tried it in both C:\java stuff (where I have the Test.class file) and in just straight C:\.

If you're not too tired of these, help would be appreciated.

Thanks!
Mani Ram
Ranch Hand

Joined: Mar 11, 2002
Posts: 1140
Is your class with in some package?


Mani
Quaerendo Invenietis
Shaan Shar
Ranch Hand

Joined: Dec 27, 2005
Posts: 1249

Don't write

Don't do: java Test.class

Do: just type java Test


Because Java run the class files without the ".class"
Mani Ram
Ranch Hand

Joined: Mar 11, 2002
Posts: 1140
Originally posted by Ankur Sharma:
Don't do: java Test.class


Hmmm....that's what he said, isn't it?

Originally posted by Jason Greenwood:

I'm not typing java Test.class
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14114
    
  16

...ext\QTJava.zip; C:\java stuff; C:\Program ...

Remove the spaces between the ; and C:\... in your classpath.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Jason Greenwood
Greenhorn

Joined: Apr 25, 2006
Posts: 3
Originally posted by Mani Ram:
Is your class with in some package?


Nope, all alone in it's own folder, straight off C.


Originally posted by Jesper Young:
...ext\QTJava.zip; C:\java stuff; C:\Program ...

Remove the spaces between the ; and C:\... in your classpath.


Ooohh... interesting... wouldn't have thought of that! Now I need to run home and change my CLASSPATH!

Thanks for the replies, all! I'll let you know if that works, Jesper!

Tony Morris
Ranch Hand

Joined: Sep 24, 2003
Posts: 1608
Originally posted by Jesper Young:
...ext\QTJava.zip; C:\java stuff; C:\Program ...

Remove the spaces between the ; and C:\... in your classpath.


Remove your CLASSPATH setting altogether and start again.
This QuickTime software seems to be causing a myriad of problems when it sets the CLASSPATH during install.


Tony Morris
Java Q&A (FAQ, Trivia)
 
Consider Paul's rocket mass heater.
 
subject: The infamous "NoClassDefFoundError"