I need to run my Java application on Mac. I could find this tutorial to use Xcode to bundle the application. The tutorial asks readers to have access to Jar Bundle application butI could not find it in the /Developer/Applications/Java Tools/ folder.
After that I came across this answer which seems is offering a good method to do it.
However, I am wondering if there is any better way to get the job done rather than the one mentioned there.
The Mac OS X utilities Jar Bundler, Icon Composer, and PacakgeMaker are all deprecated. Even the various AppBundler projects out there seem destine to fade away.
The way forward looks to be javapackager, which is included in the JDK.
The -deploy -native pkg
options will convert a Java application (Executable JAR) into a native macOS installer.
Example commands:
$ jar cmf MainClass.txt ShowTime.jar *.class
$ javapackager -deploy -native pkg -srcfiles ShowTime.jar \
-appclass ShowTime -name ShowTime \
-outdir deploy -outfile ShowTime -v
Output: deploy/bundles/ShowTime-1.0.pkg
I posted a detailed tutorial at:
centerkey.com/mac/java
For better or worse, javapackager bundles the JRE and the resulting .pkg
file is over 60MB.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With