Java library inside a jar

I created a mytest.jar file with a library that contains about 30 library files, also a jar. Is it possible to place all the banks of the library inside mytest.jar so that I need to distribute only 1 bank? Maybe this can be done with a manifest? Thanks.

+4
source share
3 answers

Not out of the box. However, One-Jar does provide a solution. It works great for standalone applications, which I assume you are doing.

If you make an applet instead, One-Jar will not work.

+4
source

Loading classes from jars-inside-jars is not possible using the standard Java class loader. However, this is possible with a custom class loader, here's how UberJar works.

The maven shade plugin takes a different approach. He will unpack all the jars on which you depend, and pack them (together with his own classes) in one large jar. Then you can use a regular class loader. It is simpler and also possible without maven using jarjar .

+7
source

Typically, a jar repackaging tool, such as jarjar , is used for this purpose.

+1
source

All Articles