File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes java.lang.NoClassDefFoundError Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "java.lang.NoClassDefFoundError" Watch "java.lang.NoClassDefFoundError" New topic
Author

java.lang.NoClassDefFoundError

R Jarman
Greenhorn

Joined: Feb 08, 2005
Posts: 27
I get the following error when trying to run the file

C:\My Program Files\cTAKES\chunker\scripts\java\data\chunk\genia>java -cp . Geni
a2PTB

Exception in thread "main" java.lang.NoClassDefFoundError: Genia2PTB (wrong name
: data/chunk/genia/Genia2PTB)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown 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)


This is contents of the directory

C:\My Program Files\cTAKES\chunker\scripts\java\data\chunk\genia>dir
Volume in drive C has no label.
Volume Serial Number is 9883-718B

Directory of C:\My Program Files\cTAKES\chunker\scripts\java\data\chunk\genia

07/27/2009 03:16 PM <DIR> .
07/27/2009 03:16 PM <DIR> ..
07/27/2009 03:16 PM 552 Genia2PTB$1.class
07/27/2009 03:16 PM 1,755 Genia2PTB.class
03/15/2009 07:40 PM 2,579 Genia2PTB.java
3 File(s) 4,886 bytes
2 Dir(s) 37,659,451,392 bytes free

I have tried it with the -cp command and without. I don't have admin rights on the computer I'm using so I can't edit the System classpath. The directory I'm in has the file I'm trying to run. I have checked that and I thought putting the dot "." for the classpath would overwrite whatever is in the system classpath and just use the current directory. What am I doing wrong?
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39394
    
  28
Please have a look at the package/folder structure. Is it like this?If so, try going to the file marked XXX (which I think you have called "java" and try with
java -cp . data.chunk.genia.Genia2PTB

If you have declared a package structure in a .java file, then you need to invoke that class from outside its package structure with its fully-qualified name after "java" and "-cp ." You can get a hint of the package structure from the "wrong name" bit of the stack trace.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java.lang.NoClassDefFoundError