Java Dictionary Info.plist Keys

The Info.plist file is an XML property list file in a native Mac app bundle. It defines certain attributes of the application for use by the operating system. The Info.plist file for a Java application wrapped as an OS X application bundle contains a Java dictionary. This dictionary is just a subset of the Info.plist file that begins with:

 <key>Java</key>
    <dict>

and ends with

    </dict>

The Java dictionary allows you to set certain Java-specific attributes of your Mac app.

Inside this Java dictionary you can have key and string combinations or key and dictionary combinations, as illustrated in Listing 1.

Listing 1  Sample Info.plist Java dictionary

<key>Java</key>
    <dict>
        <key>JVMVersion</key>
        <string>1.5+</string>
        <key>MainClass</key>
        <string>com.yourCompanyName.YourApplication</string>
        <key>Properties</key>
            <dict>
                <key>apple.laf.useScreenMenuBar</key>
                <string>true</string>
            </dict>
        <key>VMOptions</key>
        <string>-Xmx512m</string>
    </dict>

Note that each key tag has a corresponding string or dict tag. Each dict tag surrounds other key/string or key/dict combinations.

Creating an Info.plist file with Jar Bundler

OS X v10.5 and later include the Jar Bundler application, located in /usr/share/java/Tools. Jar Bundler enables you to create an OS X application bundle for your Java application, complete with an automatically generated Info.plist file. You can specify keys for the Info.plist file in the Properties tab of Jar Bundler, or you can easily modify the file to suit your needs with the Property List Editor application (also located in /Developer/Applications/Utilities) after generating the bundle.

For more information on Jar Bundler, see Jar Bundler User Guide.

Variables

In the Java dictionary of an Info.plist file, the following variables are used to specify pathnames:

$JAVAROOT

The default Java root directory for an application bundle is Contents/Resources/Java. Use this variable to refer to that directory.

$APP_PACKAGE

This variable expands into the path to the root directory of the application bundle.

$USER_HOME

This variable expands into the path to the current user’s home directory.

Keys and Values

This section lists the keys and their valid settings for the Java dictionary of the Info.plist file.

MainClass

This is a required key. It designates the name of the class containing the application’s main method. If the classes are included in your application as a JAR file, use the main class’s fully qualified class name, including its package, to locate the class within the JAR file.

JVMVersion

This key is recommended in any Java application’s Info.plist file. It specifies the earliest version of Java that is compatible with the application. Table 1 lists valid strings for the JVMVersion key along with a description of which version of Java is used. Specifying a string with the asterisk (*) symbol is not recommended, because it may prevent your application from running in the latest Java VM available.

Note:  If you do not set the JVMVersion key in a double clickable application, it runs in the first compatible version of Java specified by the user in the precedence list in the Java Preferences application.

Table 1  Values for specifying the Java version in OS X

String

Java version used

Notes

1.4*

1.4.2

Specifies the highest version of Java 1.4 available. If no version of Java 1.4 is present, the default version of Java in Java Preferences is used. This string is not recommended.

1.4+

5.0

Specifies the highest version of Java above 1.4. Note that if Java is updated in future releases of OS X, the latest version of Java is used.

1.5*

5.0

Specifies the highest version of J2SE 5.0 available. If no version of J2SE 5.0 is present, the default version of Java in Java Preferences is used. This string is not recommended.

1.5+

5.0

Specifies the highest version of Java above 5.0. Note that if Java is updated in future releases of OS X, the latest version of Java is used.

1.6*

6

Specifies the highest version of Java SE 6 available. If no version of Java SE 6 is present, the default version of Java in Java Preferences is used. This string is not recommended.

1.6+

6

Specifies the highest version of Java above Java SE 6. Note that if is updated in future releases of OS X, the latest version of Java is used.

Note: The Java Preferences application, in /Applications/Utilities/, determines how these keys are interpreted. Users can change a precedence list that determines how the keys ending in a plus sign are interpreted. If a user places J2SE 1.4.2 over J2SE 5.0 in the precedence list, the 1.4+ key results in J2SE 1.4.2 being used for the application.

ClassPath

The path for required directories or JAR files. If you do not set this, the default class path is the root of the application bundle ($APP_PACKAGE).

The following architecture-specific class-path keys are also supported. Options provided to these keys are appended to the options provided to ClassPath on systems with the corresponding architecture.

  • ClassPath.ppc

  • ClassPath.i386

  • ClassPath.x86_64

WorkingDirectory

The current working directory for the application from the default working directory at the root of the application bundle ($APP_PACKAGE).

Arguments

A string or array of strings where each string is a space-separated list of arguments to pass to main as a String[] . This is useful if your application expects to receive arguments passed in from the command line.

Properties

A subdictionary of the Java dictionary. Valid keys for the Properties dictionary are system properties that you might pass into java from the command line with the -D flag. A list of Apple-specific properties is available in Java System Property Reference for Mac.

Since the Properties key designates a dictionary, make sure to begin and end it with the dict keyword. “What is an Info.plist Java Dictionary Key?” shows an example of how to use the Properties dictionary.

VMOptions

An array of string elements in which each string is an option for the Java virtual machine. For example:

<key>VMOptions</key>
<array>
<string>-Xms512m</string>
<string>-Xmx1024m</string>
</array>

A list of Apple-specific Java VM options is available in Java Virtual Machine Option Reference for Mac.

The following architecture-specific VM-option keys are also supported. Options provided to these keys are appended to the options provided to VMOptions on systems with the corresponding architecture.

  • VMOptions.ppc

  • VMOptions.i386

  • VMOptions.x86_64

JVMArches

A list of the architectures preferred by the application. (Deprecated. Use the lipo tool or the LSArchitecturePriority key instead.)

Note: The preferred way to express an architecture dependency is to use the lipo tool to remove the unsupported architectures from the JavaApplicationStub included in the application bundle. Developers should also use the LSArchitecturePriority key in the top level of the Info.plist file, as native Mac apps do. See Launch Services Release Notes for more information.