I run the following command:
C:\\Projects\\java -cp ./dependency.jar -jar ./dist/main.jar
Exception in thread \"main\" java.lang.NoClassDefFoundError: MyExceptio
The -cp
options is ignored if you use -jar
. If you need extra jar-files on the class-path, you should specify this in the Manifest of main.jar
like this:
Class-Path: dependency.jar
(Then you can run your program using java -jar main.jar
.)
Related questions:
Have you tried specifying the class path in the windows environment variable CLASSPATH ?
specify your environment variable CLASSPATH and put the value of your JAVA_HOME\lib and (path to all your classes) and also include current directory by including (dot or period sign).