Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java library inside jar

I have created mytest.jar file with library that contains near 30 library files also jar. Is it possible to put all library jars inside mytest.jar so that I need to distribute only 1 jar? May be it can be done using manifest? Thanks.

like image 462
Lorenzo Manucci Avatar asked Dec 12 '22 11:12

Lorenzo Manucci


2 Answers

Loading classes from jars-inside-jars is not possible with the standard Java classloader. However it is possible using a custom classloader, this is how for example UberJar works.

The maven shade plugin takes a different approach. It will unpack all the jars you depend on, and pack them (along with your own classes) into one big jar. Then the normal classloader can be used. This is simpler, and is also possible without maven using jarjar.

like image 196
Matthew Gilliard Avatar answered Dec 21 '22 22:12

Matthew Gilliard


Not out of the box. However, One-Jar provides a solution. It works fine for standalone apps, which is what I assume you' re making.

If you're making an applet instead, One-Jar won't work.

like image 37
Bart van Heukelom Avatar answered Dec 21 '22 23:12

Bart van Heukelom