Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to distribute Java application 7.0 and above on Mac 10 and above?

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.

like image 289
Jack Avatar asked Oct 20 '22 19:10

Jack


1 Answers

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

screenshot

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.

like image 77
Dem Pilafian Avatar answered Oct 29 '22 03:10

Dem Pilafian