Java : create jar executable with dependant jars embedded

前端 未结 2 1334
逝去的感伤
逝去的感伤 2020-12-04 02:17

I have created an executable JAR with the manifest:

Manifest-Version: 1.0
Main-Class: MyClass
Class-Path: lib/ext.jar

I can successfully ru

相关标签:
2条回答
  • 2020-12-04 03:11

    Java doesn't have out-of-the-box support for embedding a jar within a jar. It can be achieved by writing a custom class loader, or using a tool that's already been written for this purpose: Fat Jar.

    0 讨论(0)
  • 2020-12-04 03:12

    The default Java class loader cannot find an embedded jar inside a jar file. You will need to set your Java program to use a class loader which can deal with embedded jar files. As fas as I know, I have not seen one in any opensource libraries so you may need to write one yourself.

    Alternatively, you can extract all the jar files and combine the the content into a single jar file.

    Clean way to combine multiple jars? Preferably using Ant

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