Java using “-cp” and “-jar” together

后端 未结 4 1703
温柔的废话
温柔的废话 2021-01-18 01:04

Folks,

Earlier, I had just one jar file and the manifest was set up such that I can simply run my program as:

 java -jar MyApp.jar

4条回答
  •  鱼传尺愫
    2021-01-18 01:36

    I have a Manifest.mf file like this.

    Manifest-Version: 1.0
    Main-Class: com.mycompany.mypackage.App
    Class-Path: MyApp.jar MyCore.jar log4j.jar 
    

    You can just add any jar files you need to the Class-Path line. Then as long as the jars are in the class path you can run the java -jar command without -cp.

提交回复
热议问题