Packaging your Java application for the Mac

The Mac has some nice tools to turn your jar file into a first class Mac application. This is most useful if the application has a GUI interface; Swing, SWT, etc. There are three parts to this process:

  1. Package your application as a jar file
  2. Create an icon for your application
  3. Create an application bundle

Some applications referenced below may not be installed on your Mac by default. If not, you can either install them from your distribution or download them.

I assume you already know how to do step one so we’ll move on to step two.

Find an icon you like for your application. A little Googling will produce a variety of free icons. The png file format will work for you. Be sure to follow any licensing restrictions that apply to your icon and do the following:

  1. Download the png file.
  2. Open the Icon Composer application (its in /Developer/Applications/Utilities).
  3. Drag the png file into the largest box in the icon composer.
  4. From the largest box drag it to the next largest then the next and so on to create various size icons. Be sure to go from larger to smaller for the best results.
  5. Choose File->Save in the Icon Composer and save your new icns file.

Finally, build your application bundle:

  1. Open the Jar Bundler (its in /Developer/Applications/Utilities).
  2. Select the Classpath and Files tab and add your jar file to the classpath.
  3. Select the Build Information tab.
  4. Click Choose next to the Main Class drop down, select your application’s jar file again.
  5. Select the entry point for you application from the Main Class drop down.
  6. Select your JVM Version from the drop down
  7. Click Choose Icon and select the icns file you created above.
  8. Click Create Application, enter a name for your bundle, and click Create

Now you have an application bundle file you can just drop in your /Applications directory to install.

One thought on “Packaging your Java application for the Mac

Leave a Reply

Your email address will not be published. Required fields are marked *

*

*