Classpath including JAR within a JAR

前端 未结 13 1567
自闭症患者
自闭症患者 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 02:49

    If you're trying to create a single jar that contains your application and its required libraries, there are two ways (that I know of) to do that. The first is One-Jar, which uses a special classloader to allow the nesting of jars. The second is UberJar, (or Shade), which explodes the included libraries and puts all the classes in the top-level jar.

    I should also mention that UberJar and Shade are plugins for Maven1 and Maven2 respectively. As mentioned below, you can also use the assembly plugin (which in reality is much more powerful, but much harder to properly configure).

提交回复
热议问题