This page collects information about
Java development on Mac OS X. Note that some of these resources deal specifically with Apple's now obsolete implementations of Java 6 and older, not the current OpenJDK implementations of Java 7 and 8 (which mostly behaves like the Linux implementation).
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: 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 I bundle my Java application so that it looks like a native OS X application?
A: There's a
third-party Ant task which makes a jar Mac-friendly, allowing you to provide an icon and other Mac-specific settings.
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):
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/ Android on OS X?
A: The JME SDK 3.0 was available (although without Blu-Ray support, which Macs don't support), but it has apparently been withdrawn. An SDK for JME 8 is not available. See
this discussion for some other options. The Android SDK is
available for OS X.
Useful Resources
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.
Tailoring Java Applications for Mac OS X : Tips on how to make a Java application behave more Mac-like on OS X. The document is marked obsolete, but still contains good advice. New Control Styles available on Mac OS X 10.5 outlines further possibilities to provide a more Mac-like Swing appearance.
Apple's Java Development Guide.
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."
CategoryFaq