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


Subha Rangu

Joined: Jul 23, 2004
Posts: 29
I am getting the following Exception. I was not able to trace out what the problem could be.

C:\workspace\onDemand\odwekTest\JavaSource\com>dir *.class
08/25/2004 01:03 PM 683 Logon1.class
08/25/2004 01:32 PM 716 Test.class
2 File(s) 1,399 bytes
0 Dir(s) 23,850,209,280 bytes free
C:\workspace\onDemand\odwekTest\JavaSource\com>java Test

Exception in thread "main" java.lang.NoClassDefFoundError: Test (wrong name: com
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(
at Method)
at java.lang.ClassLoader.loadClass(
at sun.misc.Launcher$AppClassLoader.loadClass(
at java.lang.ClassLoader.loadClass(
at java.lang.ClassLoader.loadClassInternal(

Please let me know if anyone came thru this exception. I have strong feeling that some problem with classpath but I did set the path as well.
Please suggest me
Kedar Bhawarthi

Joined: Jun 21, 2004
Posts: 10
i manage to get exatly same stacktrace
in my case i was declearing my class as member of some package and trying to run it as if it is member of default package ( just java <classname> .
i guess same thing happens with you to run it properly simply go one directory back and say 'java com.Test' if Test class is decleared as public in com package it will work.
somkiat puisungnoen
Ranch Hand

Joined: Jul 04, 2003
Posts: 1312
Before run program : you must set classpath follow this

and Run program like this

>> java com.Test

Java Developer, Thailand
Siripa Siangklom
Ranch Hand

Joined: Jan 26, 2004
Posts: 79
Your current directory should be in C:\workspace\onDemand\odwekTest\JavaSource\

prompt>java -classpath . com.Test
Fabrizio Gianneschi
Ranch Hand

Joined: Nov 29, 2001
Posts: 70
Your class is in the "com" package.
So you should go back one folder and invoke the java command from that position.

>cd ..
>java com.Test

Fabrizio Gianneschi<br />SCPJ2, SCWCD, SCBCD
I agree. Here's the link:
subject: NoClassDefFoundError
jQuery in Action, 3rd edition