This page collects information about Java development on the Apple Macintosh.
Q: How do I compile my first Java program on my Mac?
A: Simplest way is to use a text editor and the Terminal application that comes with your Mac, as described here.
Q: Why are Apple's Java releases continuously behind Sun's?
A: For most people this is not the big deal it's being made out to be, annoying though it may be. See here for some discussion.
Q: How do I properly set up Tomcat on OS X, with its own user account and everything?
A: Luckily, someone has taken the time to write it all down; get all the details here, and there's also good information at http://wiki.apache.org/tomcat/TomcatOnMacOS.
Q: How do bundle my Java application so that it looks like a native OS X application?
A: Apple provides a tool called Jar Bundler for this purpose, which is part of the Xcode Development Tools. It can bundle any number of jar files inside a Cocoa launcher, helps provide a proper icon and application menu title, and more.
You can use the hdiutil tool to create a disk image; type man hdiutil on the command line to learn more about it. It can be invoked from an Ant build like this (assuming that MyApplication.app is the application built by Jar Bundler):
<exec executable="hdiutil" os="Mac OS X">
There's also a third-party Ant task which does something similar.
JWrapper creates a native OSX app along with other platforms.
If you need a native OS X installer for your Java application, the way to do it is described here.
Q: Can I develop for JME (Java Micro Edition) and/or Android on OS X?
A: The JME SDK 3.0 is available from Sun (although without Blu-Ray support, which Macs don't support). Also see this discussion for some other options. The Android SDK is also available for OS X.
Q: Is it possible to customize the Swing Aqua L&F?
A: Yes, a few options have been written up here.
Q: My applet was compiled with Java 6, but it doesn't run on the Mac; what gives?
A: Not all versions of OS X support all versions of Java. For example, OS X 10.4 does not support Java 6. All the details can be found in Apple's Technical Note 2110.
- Apple OSXAdapter code sample : Apple's Java implementations provides several useful classes that allow a Java application to make use of Mac-specific functionality, particularly how to receive events and display menus in the Application menu, which is otherwise out of reach for Java code. This sample demonstrates how to use these classes.
- AppleJavaExtensions : In order to compile code that uses the Apple-specific classes on other platforms, these stub classes can be used at compile time on non-OS X platforms. The javadocs of those classes are here
- Identifying Java on Mac OS X provides an overview of which Java version runs on which OS X version, and how they can be detected at runtime.
- Make Your Swing App Go Native (part1 part2 part3) is a series of articles about how to make Swing applications behave according to the OS they run on, with particular emphasis on OS X and Windows.
- Greg Guerins Software includes a variety of examples of how to access Mac-specific frameworks through JNI. These haven't been updated in quite a while, so it's possible that they no longer work with current versions of OS X.
- Mac Widgets for Java "Mac Widgets for Java are a collection of widgets seen in OS X applications, offered in a Java API. These widgets help Java developers create more Mac-like applications. There usage is not restricted to Mac though, as they will render across platforms."