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:
- Package your application as a jar file
- Create an icon for your application
- 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:
- Download the png file.
- Open the Icon Composer application (its in /Developer/Applications/Utilities).
- Drag the png file into the largest box in the icon composer.
- 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.
- Choose File->Save in the Icon Composer and save your new icns file.
Finally, build your application bundle:
- Open the Jar Bundler (its in /Developer/Applications/Utilities).
- Select the Classpath and Files tab and add your jar file to the classpath.
- Select the Build Information tab.
- Click Choose next to the Main Class drop down, select your application’s jar file again.
- Select the entry point for you application from the Main Class drop down.
- Select your JVM Version from the drop down
- Click Choose Icon and select the icns file you created above.
- 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.