Classpath including JAR within a JAR

前端 未结 13 1400
自闭症患者
自闭症患者 2020-11-22 02:21

Is it possible to specify a Java classpath that includes a JAR file contained within another JAR file?

13条回答
  •  死守一世寂寞
    2020-11-22 03:14

    After some research I have found method that doesn't require maven or any 3rd party extension/program.

    You can use "Class-Path" in your manifest file.

    For example:

    Create manifest file MANIFEST.MF

    Manifest-Version: 1.0
    Created-By: Bundle
    Class-Path: ./custom_lib.jar
    Main-Class: YourMainClass
    

    Compile all your classes and run jar cfm Testing.jar MANIFEST.MF *.class custom_lib.jar

    c stands for create archive f indicates that you want to specify file v is for verbose input m means that we will pass custom manifest file

    Be sure that you included lib in jar package. You should be able to run jar in the normal way.

    based on: http://www.ibm.com/developerworks/library/j-5things6/

    all other information you need about the class-path do you find here

提交回复
热议问题