• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NoClassDefFoundError: wrong name

 
Elton Hughes
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try:

java org.novaworks.ch02.HelloWorld
 
Ko Ko Naing
Ranch Hand
Posts: 3178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic