Additional jar files for java.exe -jar

前端 未结 2 1872
礼貌的吻别
礼貌的吻别 2021-01-24 15:08

I run the following command:

C:\\Projects\\java -cp ./dependency.jar -jar ./dist/main.jar
Exception in thread \"main\" java.lang.NoClassDefFoundError: MyExceptio         


        
相关标签:
2条回答
  • 2021-01-24 15:53

    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:

    • When creating a jar file how do I retain the existing classpaths to other jar files?
    • Cannot find class even when jar file is in working directory
    • Jetty Classpath issues
    • problem related to MANIFEST.MF in jar
    0 讨论(0)
  • 2021-01-24 15:54

    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).

    0 讨论(0)
提交回复
热议问题