The following sections outline the support provided by Mac OS X for creating Java-based programs.
Note: The developer documentation on the Apple website contains an entire section devoted to Java. There you can find detailed information on the Java environment and accompanying technologies for operating in Mac OS X. For an introduction to the Java environment and pointers to relevant documentation on Java programming in Mac OS X, see Getting Started with Java.
The Java Environment
Java and Other Application Environments
The libraries, JAR files, and executables for the Java application environment are located in the /System/Library/Frameworks/JavaVM.framework directory. The Java application environment has three major components:
A development environment, comprising the Java compiler (javac) and debugger (jdb) as well as other tools, including javap, javadoc, and appletviewer. You can also build Java applications using Xcode.
A runtime environment consisting of Sun’s high-performance HotSpot Java virtual machine, the “just-in-time” (JIT) bytecode compiler, and several basic packages, including java.lang, java.util, java.io, and java.net.
An application framework containing the classes necessary for building a Java application. This framework contains the Abstract Windowing Toolkit (java.awt) and Swing (javax.swing) packages, among others. These packages provide user interface components, basic drawing capabilities, a layout manager, and an event-handling mechanism.
Like Carbon and Cocoa applications, a Java application can be distributed as a double-clickable bundle. The Jar Bundler tool takes your Java packages and produces a Mac OS X bundle. This tool is installed along with Xcode and the rest of the Apple developer tools on the Xcode Tools CD.
If you want to run your Java application from the command line, you can use the java command. To launch a Java application from another program, use the system exec call or the Java Runtime.exec method. To run applets, embed the applet into an HTML page and open the page in Safari.
Java applications can take advantage of Mac OS X technologies such as Cocoa and QuickTime through Sun’s Java Native Interface (JNI). For details on using the JNI on Mac OS X, see Technical Note 2147.
Last updated: 2007-10-31