How to execute jar file with a external dependency using command line on Windows?

后端 未结 2 1445
长发绾君心
长发绾君心 2021-01-21 05:49

I have jar file with manifest in it

    Manifest-Version: 1.0
    Build-Jdk: 1.7.0_67
    Created-By: Apache Maven 3.2.3
    Main-Class: com.company.main.Main
           


        
2条回答
  •  春和景丽
    2021-01-21 06:28

    If you're not using the -jar option then you need to specify the main class to run, as the manifest will not be interrogated:

    java -cp C:\commons-lang3-3.3.2.jar;.\myJar-1.0.0.jar com.company.main.Main
    

    The classpath (-cp) option is ignored if using the -jar option (in that case the manifest should reference any other required jars via its classpath directive).

提交回复
热议问题