jQuery in Action, 3rd edition
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 Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "NoClassDefFoundError: wrong name" Watch "NoClassDefFoundError: wrong name" New topic

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.


Yevgeniy Treyvus
Ranch Hand

Joined: Mar 09, 2005
Posts: 48

java org.novaworks.ch02.HelloWorld

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
I agree. Here's the link: http://aspose.com/file-tools
subject: NoClassDefFoundError: wrong name
It's not a secret anymore!