Exception in thread main java.lang.NoClassDefFoundError
Writing by shivdev on Monday, 12 of October , 2009 at 9:18 pm
After getting used to the spoon-feeding IDE’s, writing some one-off classes might lead to this Exception.
Exception in thread “main” java.lang.NoClassDefFoundError: HelloWorld
Caused by: java.lang.ClassNotFoundException: HelloWorld
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
Could not find the main class: HelloWorld. Program will exit.
Very common problem. Your classpath needs a .: followed by the classpath, to include the class(es) in your current directory.
java -cp .:./lib/mysql.jar HelloWorld
Leave a comment
Category: Java
- Add this post to
- Del.icio.us -
- Digg -
- -
- Tweet -
-
-