IBM Support

Changing Default Version for JDK (java.version)

Technote (troubleshooting)


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:

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 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 file in your own user.home path. This file and the properties that it contains override those in /QIBM/UserData/Java400/ 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 file in /home/John/.

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


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/')

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:


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


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

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:
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 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:

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:


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:

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


Document information

More support for: IBM i

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