Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java9 packager with jlink compress tags

when we create jlink runtime images we can use tags such as '--strip-debug', '--compress', '2', '--no-header-files', '--no-man-pages' , creating a distribution folder around 45mb.

If we want to use javapackager, for example to create an .DMG file, how can we do a similar compression? since these tags are not avaiable for javapackager. Without them the final bundle is around 100mb, losing a lot the java9 modularization advantages, so my question is if it is possible to use javapackager with JRE runtime images created by jlink.

thanks

like image 358
Tiago Santos Avatar asked Nov 14 '17 13:11

Tiago Santos


1 Answers

Answering my own question, we can just use the combination of two:

For MacOSX example:

1) generate a runtime dist with jlink, this will create a lib folder with around 50mb if you use compress tags.

2) Generate MacOSX.app with javapackager, this .app will come with a runtime lib folder around 98mb.

3) Simple replace them, right click MacOSX.app-> "show package contents", then go to Plugins/Java.runtime/Contents/Home/ and replace lib folder with the one generated by jLink.

This way you have a self-contained Java app with around 50mb instead of 100mb, thanks to beautiful Java9 modules.

Would be cool to do all of this just with javapackager, if it's possible I couldn't find how, I suggest to use something like gradle to execute all this process with 1 command.

like image 118
Tiago Santos Avatar answered Nov 02 '22 05:11

Tiago Santos