Using Java for a Mac OS X Desktop App

I developed Poker Copilot in Java on Mac OS X Leopard. This was the first time I created a Java-based Mac OS X app. In all, it was a positive experience, and preferable to doing the same with Windows.

Not all was good though. Currently Mac OS X Java apps must use Java 5. Although Java 6 has been released for Mac OS X it is not the current default JVM. It’s frustrating having to write code or import code that is included with Java 6. Table sorting is a good example. In Java 6 adding sorting to a table is as easy as this:


In Java 5 – and therefore for Macs – you need to do a bit of hackery.

Now the praise starts. On Mac OS X you always know that your user has the correct JRE. Under Windows you never know what JRE version (if any) a user has. From time to time releases of Java have regression bugs that cause support nightmares, and it may be that your user has such a JRE version. For example, a beta release of Java 6 didn’t show toolbar icons under Windows. I wonder how many support engineers from various companies tore their hair out trying to solve that one. Eventually most Java-based Windows products start shipping with a private JRE to avoid these problems.

On Mac OS X this is unnecessary. Java is distributed with every Mac and updated as part of Apple Update. I can be certain that my users have the correct version of Java on their machine.

Integration between Java apps and Mac OS X is superb. Apple has put plenty of effort into ensuring that a Java app can access much of OS X’s underlying system functionality, and can emulate the other parts. For example, want to make you window a floating palette? Simply set the appropriate client property and it is done. Even better the integration is documented and supported by Apple.

Distributing Java apps on Mac OS X is a joy compared to the awkward process on Windows. You don’t need any additional software to make your Java app install and run like any other Mac app. The instructions and tools to do this are included with the Xcode development tools found on the Leopard installation DVD.

My final praise is for Apple’s Java-dev mailing list. Apple staff and volunteers seem to quickly and willingly answer most questions. When I posed a question to this mailing list last Sunday, an Apple Java engineer gave me far more help than I expected to find the optimal solution for what I was trying to do. Within two hours we had nailed it and he wrote some sample code for me. On a Sunday!