IBM Support

Changing Default Version for JDK (java.version)

Technote (troubleshooting)


Problem(Abstract)

This document describes how to switch to a different JDK when you have multiple JDKs installed to i5/OS.

Resolving the problem

If you are running OS/400 V5R3 or older, the "Classic JVM" instructions should be followed. For i5/OS V5R4 or V6R1 (6.1), you could be using Classic JVM or IBM Technology for Java VM (J9). For releases of i5/OS that follow 6.1, Classic JVM will not be available. IBM Technology for Java VM (J9) will be the only JVM. Please note V6R1 (6.1) is out of support and requires a SWMA Support Extention. Please review the following for "Classic JVM" support:

http://www-01.ibm.com/support/docview.wss?uid=nas8N1010513



Setting JDK for "Classic JVM" (R540 and R610 ONLY)

A number of properties are set when the Java virtual machine starts. To change the version of the Java virtual machine, you will need to set the property for Java version (java.version). Use one of the following methods to set the property:

o Provide a file in /QIBM/UserData/Java400, named SystemDefault.properties. The property values that you specify in this file override the system defaults that IBM provides. This file sets the default system properties for all Java virtual machines that run on your IBM i system.
o Or, place a SystemDefault.properties file in your own user.home path. This file and the properties that it contains override those in /QIBM/UserData/Java400/SystemDefault.properties. This file sets the default system properties for all Java virtual machines that run for you. Note: This assumes that the home directory for your user profile is set to: /home/<myprofile>. For example, if my user profile is 'John', I would create the SystemDefault.properties file in /home/John/.

Following is an example of the text that must be added to the SystemDefault.properties file:

java.version=1.4

Here is a very quick and easy way to create and populate the file with one command:

QSH CMD('echo java.version=1.4 > /QIBM/UserData/Java400/SystemDefault.properties')


Setting JDK for IBM Technology for JVM (R540, R610, R710, R720, R730)

If you are familiar with the Classic JVM on i5/OS, you know that you can switch between them by setting the java.version property. The only way to use IBM Technology for JVM is by setting the JAVA_HOME environment variable.

There are three common techniques for setting JAVA_HOME:
1. Use the ADDENVVAR CL command. For example, to add the variable to your current interactive job, enter the following on a CL command line:

ADDENVVAR ENVVAR(JAVA_HOME) VALUE('/QOpenSys/QIBM/ProdData/JavaVM/jdk80/64bit’)

Use the following if you want to set the variable at the system level:

ADDENVVAR ENVVAR(JAVA_HOME) VALUE('/QOpenSys/QIBM/ProdData/JavaVM/jdk80/64bit') LEVEL(*SYS)

If you want to remove the JAVA_HOME variable type, use the following:

RMVENVVAR JAVA_HOME
2. Set JAVA_HOME from within QSHELL. For example:

a. Open a Qshell session using the STRQSH command.
b. Export the variable to your process:
export -s JAVA_HOME=/QOpenSys/QIBM/ProdData/JavaVM/jdk80/64bit
To remove the JAVA_HOME environment variable from within Qshell, use the unset command. For example, use the following:
unset JAVA_HOME
3. Use a .profile file to initialize the shell. If you would like JAVA_HOME to be set every time you start Qshell, you may create a .profile file in a user’s home directory. For example, if your i5/OS user profile is John, you would perform the following steps:
a. Create a file called .profile in /home/John.
b. Add the following text to the file:
export -s JAVA_HOME=/QOpenSys/QIBM/ProdData/JavaVM/jdk80/64bit
c. Save the file.
Note: You should not use the java.home system property to set the JDK home. This will not work on IBM i. In fact, if you attempt to set java.home in the SystemDefault.properties file, the Java product may stop working completely. The only way to change the JDK is to set JAVA_HOME as an environment variable. See the IBM Information center for more information:
http://publib.boulder.ibm.com/infocenter/iseries/v7r1m0/index.jsp?topic=%2Frzaha%2Frzahainstalljdk.htm

The behavior of JAVA_HOME is as follows:

On IBM i 5.4 (V5R4)

If JAVA_HOME is not set, or set to the empty string, all forms of Java invocation uses the i5/OS default Classic JVM implementation. If the Classic JVM is not installed, IBM Technology for JVM is used.

If java.version is set to 1.3 or 1.4, JAVA_HOME is ignored and Classic JVM is used.

If JAVA_HOME is set to a valid JVM installation directory, all Java invocations use the specified VM.

On IBM i 6.1

The default JVM is J9 5.0 32bit. So, even if JAVA_HOME is not set, a J9 JVM will be used, not a Classic JVM.

Also, at 6.1, JAVA_HOME can be used to set the default JVM to classic. For example:

JAVA_HOME=/QIBM/ProdData/Java400/jdk6

will force the default JVM to be 6.0 Classic. Prior to IBM i 6.1, the JAVA_HOME variable could not be used to refer/use any of the classic JDKs.

For a complete list of JDKs supported per OS release:

http://www-01.ibm.com/support/docview.wss?uid=nas8N1011999


Cross reference information
Segment Product Component Platform Version Edition
Operating System IBM i 6.1
Operating System IBM i 7.3
Operating System IBM i 7.2
Operating System IBM i 7.1

Historical Number

19754920

Document information

More support for: IBM i
Java

Software version: 5.3.0, 5.3.5, 5.4.0, 5.4.5, 6.1, 6.1.0, 7.1, 7.2, 7.3

Operating system(s): IBM i

Reference #: N1017748

Modified date: 07 September 2012