I’m using NetBeans IDE to code a java program. When I run the program from NetBeans it works perfectly but when I run it from command prompt I get the following:
Exception in thread "main" java.lang.NoClassDefFoundError: javaapplication/Main
Caused by: java.lang.ClassNotFoundException: javaapplication.Main
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: javaapplication.Main. Program will exit.
I used another program (myEclipse) to build the program but the exact thing happened, I’m only able to run the program from the IDE and not command prompt.
Well, is
javaapplication.Mainmeant to be the main class? If not, it’s probably a mistake in the manifest file.If it is meant to be the main class, look inside the jar file (e.g. by extracting it). Look for a directory called javaapplication which should have a file called Main.class in.
One of those two things is wrong, but we can’t really tell what it is from here – only you can.