IBM Support

Changing Default Version for JDK (java.version)



This document describes how to switch to a different JDK when you have multiple JDKs installed to your IBM i OS.

Resolving The Problem

If you are running IBM i V5R3 or older, the "Classic JVM" instructions should be followed. For IBM i V5R4 or V6R1 (6.1), you could be using Classic JVM or IBM Technology for Java VM (J9). For releases of IBM i 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, R740)

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:
Use the ADDENVVAR CL command. For example, to add the variable to your current interactive job, enter the following on a CL command line:
Java 8 Example:

Java 11 Example:
Use the following if you want to set the variable at the system level:
Java 8 Example:
Java 11 Example:

If you want to remove the JAVA_HOME variable type, use the following:
RMVENVVAR JAVA_HOME LEVEL(*SYS) - System wide removal
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:
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.
Java 11 JAVA_HOME is JAVA_HOME=/QOpenSys/QIBM/ProdData/JavaVM/jdk11/64bit
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:

[{"Type":"MASTER","Line of Business":{"code":"LOB08","label":"Cognitive Systems"},"Business Unit":{"code":"BU054","label":"Systems w\/TPS"},"Product":{"code":"SWG60","label":"IBM i"},"ARM Category":[{"code":"a8m0z0000000CH5AAM","label":"Java Development Kit"}],"ARM Case Number":"","Platform":[{"code":"PF012","label":"IBM i"}],"Version":"All Versions"}]

Historical Number


Document Information

Modified date:
09 September 2021