aspose file tools*
The moose likes Java in General and the fly likes NoClassDefFoundError: wrong name Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "NoClassDefFoundError: wrong name" Watch "NoClassDefFoundError: wrong name" New topic
Author

NoClassDefFoundError: wrong name

Elton Hughes
Ranch Hand

Joined: Jun 19, 2003
Posts: 72
Hello All,

I am trying out Velocity for the first time and I have written a simple program.


It compiles, but when I run the program I get the following message.

-> java HelloWorld
Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorld (wrong name: org/novaworks/ch02/HelloWorld)
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:539)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:251)
at java.net.URLClassLoader.access$100(URLClassLoader.java:55)
at java.net.URLClassLoader$1.run(URLClassLoader.java:194)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)
at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
->

Unfortunately, I do not understand the error message. Everything looks correct to me. Maybe someone else's eyes can help me out.

Thanks!

Elton
Yevgeniy Treyvus
Ranch Hand

Joined: Mar 09, 2005
Posts: 48
Try:

java org.novaworks.ch02.HelloWorld


SCJP, SCJD
Ko Ko Naing
Ranch Hand

Joined: Jun 08, 2002
Posts: 3178
Yevgeniy is right, Elton...

To second that, you should be in the folder that is the parent folder of org/novaworks/ch02/ path... Then since your HelloWorld java application is in that package, you have to specify the full correct path to the package so that JVM can see that...

Hope my explanation helps...


Co-author of SCMAD Exam Guide, Author of JMADPlus
SCJP1.2, CCNA, SCWCD1.4, SCBCD1.3, SCMAD1.0, SCJA1.0, SCJP6.0
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: NoClassDefFoundError: wrong name
 
Similar Threads
why is this happening REALLY URGENT
What is the role of /Library/Java/Extentions ?
running java program out of workspace
HelloWorldSwing
Velocity Error:Resource Not Found Exception