How to distribute a .jar on mac using .dmg with Drag & Drop?


I need to convert a .jar into .app that includes JRE inside to be able to distribute in MacOS Sierra as a file .dmg with Drag & Drop without the need to install JDK or JRE (that already comes included in .app ).

asked by Angel Montes de Oca 12.09.2017 в 20:34

1 answer


The way to convert a .jar to an .app file (native to mac) with the JRE inside and ready to run on any mac and in a simple way, is using javapackager: a simple way to use it is by installing the JDK in MacOS.

We can verify the version of the javapackager in terminal with the following command:
javapackager -version

It will give a result similar to:

Java Packager version 8.0  

The way to do it is as follows:

javapackager \
> -deploy \
> -title TituloApp \
> -name NombreApp \
> -appclass \
> -native dmg \
> -outdir ~/Desktop \
> -outfile out \
> -srcfiles elJarQueDeseasConvertir.jar

At the end we will have (in case of selecting ~ / Desktop as output directory) a folder on the desktop called bundles where the file .dmg Drag & Drop will be with the .app inside and JRE integrated to run without installing anything else, only remains to modify the logos and the fund, which is very easy and can be found on the internet how to do it.

Oracle Documentation about javapackager

answered by 12.09.2017 / 20:34