This chapter provides information on packaging your application so that it can require J2SE 5.0. It also includes the steps you need to take when developing J2SE 5.0 applications on Mac OS X v.10.4.
Java Versioning
Java Developer
The default version of Java after installing J2SE 5.0 Release 3
Java 1.4.2 remains the default version of Java used by applications and applets after installing J2SE 5.0 Release 3.
This allows applications built for Java 1.4.2 to continue running in Java 1.4.2.
To use the J2SE 5.0 version of any command-line Java utility, such as java
or javac
, specify the full path to the J2SE 5.0 version of the command. This usually means prepending the command with the path /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Commands/
.
The JVMVersion
Info.plist key allows you to specify which Java virtual machine your application uses. Using either the 1.3+, 1.4+, or 1.5+ keys results in the Java virtual machine being used according to a precedence list set in the Java Application Settings portion of the Java Preferences application, found in /Applications/Utilities/Java/J2SE 5.0
. By default in J2SE 5.0 Release 3, the precedence list follows this order:
J2SE 1.4.2 |
J2SE 5.0 |
Though not listed, Java 1.3.1 is considered to be the last entry on the list.
This works by trying to match the given key versus Java virtual machine versions in the list:
Having 1.4+ specified first matches the “J2SE 1.4.2” value, so that is the Java virtual machine used. Specifying 1.5+ means that 1.4.2 is skipped and the next choice, “J2SE 5.0,” is used.
If a user switches these values so that “J2SE 5.0” is first, an application that specifies 1.4+ runs in J2SE 5.0, since it’s the first entry and numerically superior to Java 1.4.2.
Table 1-1 lists the possible combinations of values when working with JVMVersion
values and the Java Version Precedence List found in Java Preferences.
Possible JVMVersion Value | Java virtual machine used if “J2SE 1.4.2” is listed first in Java Version Precedence List (Default) | Java virtual machine used if “J2SE 5.0” is listed first in Java Version Precedence List |
---|---|---|
| J2SE 5.0 | J2SE 5.0 |
| J2SE 5.0 | J2SE 5.0 |
| Java 1.4.2 | J2SE 5.0 |
| Java 1.4.2 | Java 1.4.2 |
| Java 1.4.2 | J2SE 5.0 |
| Java 1.3.1 | Java 1.3.1 |
You can specify a specific version of Java as your JVMVersion
key (such as 1.4.2 or 1.5.0), but if that precise version is not installed on the system, your application will fail to launch. This is not recommended.
To use an applet in Safari using J2SE 5.0, use the Applet portion of the Java Preferences application to select J2SE 5.0 as the virtual machine for applets. Java Preferences is found in /Applications/Utilities/Java/J2SE 5.0
,
For information on configuring Xcode projects for use with J2SE 5.0, read “Xcode Java Projects in J2SE 5.0.”
Xcode Java Projects in J2SE 5.0
The Java project templates in Xcode are set up for use with Java 1.4.2.
Follow these steps to modify projects for use with J2SE 5.0:
Double click the target to edit and provide /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Commands/javac
as the value for the JAVA_COMPILER
build setting, available in the Expert View. Change the Target VM Version
and Source Version
in the Java Compiler Setting
to use 1.5
.
Double click the executable named java
and enter /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Commands/java
as the Executable Path
in the General tab of Executable info.
Double click the executable named appletviewer
and enter /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Commands/appletviewer
as the Executable Path
in the General tab of Executable info.
The Java Xcode project templates are currently set to specify a JVMVersion
of 1.4*
, meaning that your compiled application runs in Java 1.4.2. To run your application in J2SE 5.0, set the Target VM Version
to 1.5*
:
Open the Target window for your application's build target
Select the Pure Java Specific
listing under Info.plist Entries
For the Target VM Version
field, enter 1.5*
J2SE 5.0 Reference Documentation
The J2SE 5.0 Reference Documentation is not installed automatically.
Install the J2SE 5.0 Release 3 Documentation package, available from the Downloads > Java page at http://connect.apple.com.
Note: J2SE 5.0 symbols are not used in the Xcode Documentation window by default. To use the 5.0 symbols instead of the 1.4.2 symbols, you need to modify which version of Java is indexed. To do this, follow the directions outlined in the workaround for “J2SE 5.0 symbols not visible in Xcode Documentation window.”
J2SE 5.0 symbols not visible in Xcode Documentation window
After installing the J2SE 5.0 Reference documentation or a documentation update in Xcode, J2SE 5.0 symbols are not present in the Xcode documentation window.
You need to manually run the pbhelpindexer
utility for the J2SE 5.0 symbols to appear in the Xcode Documentation window. First, open MacOSXDeveloper.pbHelpIndexerList
, located at:
/Developer/ADC Reference Library/indexes/ |
Replace this path:
/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Resources/ |
With this path:
/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Resources/ |
Finally, run this command in Terminal (it may take a while to finish executing):
sudo /Developer/Tools/pbhelpindexer |
© 2006 Apple Computer, Inc. All Rights Reserved. (Last updated: 2006-01-10)