File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Fun runtime issues! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Fun runtime issues!" Watch "Fun runtime issues!" New topic

Fun runtime issues!

David Miranda
Ranch Hand

Joined: Mar 14, 2005
Posts: 34
Hi all,

I've developed some java code in the NetBeans IDE 4.1, it compiles and runs fine in NetBeans.

I want to try to run to same code via command line. I get this message:

Exception in thread "main" java.lang.NoClassDefFoundError: testproject/build/cla
sses/testproject/testprog (wrong name: testproject/testprog)
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at Source)
at Source)
at$100(Unknown Source)
at$ Source)
at Method)
at Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)

Pretty common issue on these forums, so I researched what people did to fix them. I checked my class path variables (both user and system), they are both:

The class file (testprog.class) is saved in this directory:

I go to the c:\NetBeans_projects directory and type:

And I get the error above, I've also tried:
java testproject/build/classes/testproject/testprog
java testproject\build\classes\testproject\testprog

None of them work.

Also, I've tried to compile the java file (, saved at:
via command-line. It works, but saves the .class file in the src directory instead of the build directory. (But thats a separate issue)

Any idea of what I'm forgetting?

miguel lisboa
Ranch Hand

Joined: Feb 08, 2004
Posts: 1281
does your file has a package declaration?

if no, you cant type:
>java testproject\testprog, but just
>java testprog

BTW: use capital letter at begining of class name, like, or, for sake of readability,

java amateur
Arjun K
Ranch Hand

Joined: Mar 09, 2005
Posts: 39

Taken From : David Miranda
It works, but saves the .class file in the src directory instead of the build directory. (But thats a separate issue)

javac -d d:/projects/testproj/build

This will save the class file in build directory.

Arjun K.
I agree. Here's the link:
subject: Fun runtime issues!
jQuery in Action, 3rd edition