In my java program, I am importing a package from a different location. So, I set the class path and import the package. The program is compiled successfully, but It show the following Exception while running it.
D:\>java Myprogram
Exception in thread "main" java.lang.NoClassDefFoundError: Myprogram
Caused by: java.lang.ClassNotFoundException: Myprogram
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)
Could not find the main class: Myprogram. Program will exit.
Please help!
Jaganathan BantheswaranPosted Jul 22, 2011, 7:05 AM
Check whether the name of the file and name of the class is same.. and also check whether there is a class file in the package where the source file is.