When deploying a Java application on Mac OS X, you should wrap the Java application inside a native Mac OS X application bundle. This application bundle is just a directory with some information about the application itself and a native code stub to launch the Java application. You can construct an application bundle very easily with Jar Bundler which is available in /Developer/Tools. For users, the end result is a native application that is double-clickable in the Finder.
By default, existing Java applications that have been bundled as native applications run with the Java 1.3.1 VM. As such, they exhibit the same behavior as they did before installing Java 1.4.1. This behavior provides the cleanest user experience. From a user’s perspective, an application continues to work the same way it has always worked. This is important since, from the user’s perspective, the application is not necessarily a Java application, but rather a Mac OS X application.
You may determine that you want users to run your existing applications with Java 1.4.1 instead of Java 1.3.1, perhaps to take advantage of new features in the 1.4.1 version. In that case it is your responsibility to designate the appropriate version of Java for your application. You can do this by modifying the Info.plist file of the native application bundle.
Note: Even if you do not need to take advantage of Java 1.4.1, you should update your application bundle to note which version of Java you want your application to run with. Although Mac OS X version 10.2 chooses to use Java 1.3.1 if none is specified, future versions of Java or the operating system may choose otherwise.
For new applications, set the VM version in the Build Information pane of Jar Bundler, or the Pure Java-Specific pane in Project Builder’s target editor. If you are modifying an existing application, modify the JVMVersion property in the Info.plist file. This file is in the Contents folder of the application bundle. To view this file in the Finder, Control-click the application icon, then choose “Show Package Contents.”
The Info.plist file is an XML document, so you can modify it with any text editor. If there is not already a key for JVMVersion, you need to add one. This key should be in the Java dictionary. For example, the Java section of the Info.plist might look something like Listing 3-1.
Listing 3-1 Info.plist without JVMVersion property
<key>Java</key> |
<dict> |
<key>MainClass</key> |
<string>YourApplication</string> |
<key>ClassPath</key> |
<string>$JAVAROOT/YourApplication.jar</string> |
</dict> |
At the same level as the existing key and string combination for the ClassPath, add in a key value of JVMVersion and a string value from Table 3-1 as appropriate. The resulting Info.plist should look something like that shown in Listing 3-2.
Listing 3-2 Info.plist with JVMVersion property
<key>Java</key> |
<dict> |
<key>MainClass</key> |
<string>YourApplication</string> |
<key>JVMVersion</key> |
<string>1.4+</string> |
<key>ClassPath</key> |
<string>$JAVAROOT/YourApplication.jar</string> |
</dict> |
Value |
Java version used |
Notes |
|---|---|---|
1.3.1 |
1.3.1 |
Specifies an exact version of Java. |
1.3* |
1.3.1 |
Requests the highest version of Java 1.3 available. Note that if Java 1.3 is updated in future releases of Mac OS X the highest version of Java 1.3 will be used. |
1.3+ |
1.4.1 |
Requests the highest version of Java above 1.3. Note that if Java is updated in future releases of Mac OS X, the highest numbered version will be used. |
1.4.1 |
1.4.1 |
Specifies an exact version of Java. |
1.4* |
1.4.1 |
Specifies the highest version of the Java 1.4 available. Note that if Java 1.4 is updated in future releases of Mac OS X the highest version of Java 1.4 will be used. |
1.4+ |
1.4.1 |
Specifies the highest version of Java above 1.4. Note that if Java is updated in future releases of Mac OS X, the highest numbered version will be used. |
Some older applications may have an MRJApp.properties file instead of an Info.plist file. For these applications, add the following line with value set to an appropriate value from Table 3-1: com.apple.mrj.application.JVMVersion=value.
Last updated: 2003-06-11