The following program is throwing error:
public class HelloWorld { public static void main(String args[]) { System.out.println("Hello World!"); } } CLASSPATH C:\Program Files\Java\jdk1.6.0_18\bin\ Path C:\Program Files\Java\jdk1.6.0_18\bin\ JAVAHOME C:\Program Files\Java\jdk1.6.0_18\bin
Can you please tell me the root cause?
To resolve module dependency, we use the module path. However, adding external jars in the module path does not make them available for the class loader. Hence the class loader considers them as missing dependencies and throws the NoClassDefFoundError.
An exception is an issue (run time error) occurred during the execution of a program. When an exception occurred the program gets terminated abruptly and, the code past the line that generated the exception never gets executed.
I found one another common reason. If you create the java file inside a package using IDE like eclipse, you will find the package name on the top of your java file like "package pkgName". If you try to run this file from command prompt, you will get the NoClassDefFoundError error. Remove the package name from the java file and use the commands in the command prompt. Wasted 3 hours for this. -- Abhi
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With