Aug 3, 2010

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.

About the Author

Object Partners profile.

One thought on “Packaging your Java application for the Mac

Leave a Reply

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

Related Blog Posts
An Exploration in Rust: Musings From a Java/C++ Developer
Why Rust? It’s fast (runtime performance) It’s small (binary size) It’s safe (no memory leaks) It’s modern (build system, language features, etc) When Is It Worth It? Embedded systems (where it is implied that interpreted […]
Getting Started with CSS Container Queries
For as long as I’ve been working full-time on the front-end, I’ve heard about the promise of container queries and their potential to solve the majority of our responsive web design needs. And, for as […]
Simple improvements to making decisions in teams
Software development teams need to make a lot of decisions. Functional requirements, non-functional requirements, user experience, API contracts, tech stack, architecture, database schemas, cloud providers, deployment strategy, test strategy, security, and the list goes on. […]
JavaScript Bundle Optimization – Polyfills
If you are lucky enough to only support a small subset of browsers (for example, you are targeting a controlled set of users), feel free to move along. However, if your website is open to […]