Chapter 3. Selecting an installed OpenJDK version for a specific application
Some applications require a specific OpenJDK version to run. If multiple versions of OpenJDK are installed on the system using the yum
package manager or portable bundle, you can select a OpenJDK version for each application where necessary by setting the value of the JAVA_HOME
environment variable or using a wrapper script.
Prerequisites
- Multiple versions of OpenJDK installed on the machine.
- Ensure that the application you want to run is installed.
Procedure
Set the
JAVA_HOME
environment variable. For example, if openjdk-8 was installed usingyum
:$ JAVA_HOME=/usr/lib/jvm/java-8-openjdk
NoteThe symbolic link
java-8-openjdk
is controlled by thealternatives
command.Do one of the following:
Launch the application using the default, system-wide configuration.
$ mvn --version Apache Maven 3.5.4 (Red Hat 3.5.4-5) Maven home: /usr/share/maven Java version: 1.8.0_242, vendor: Oracle Corporation, runtime: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.242.b08-0.el8_1.x86_64/jre Default locale: en_US, platform encoding: UTF-8 OS name: "linux", version: "4.18.0-147.3.1.el8_1.x86_64", arch: "amd64", family: "unix"
Launch the application specifying the
JAVA_HOME
variable:$ JAVA_HOME=/usr/lib/jvm/java-8-openjdk mvn --version Apache Maven 3.5.4 (Red Hat 3.5.4-5) Maven home: /usr/share/maven Java version: 1.8.0_242, vendor: Oracle Corporation, runtime: /usr/lib/jvm/java-8-openjdk-1.8.0.242.b08-0.el8_1.x86_64 Default locale: en_US, platform encoding: UTF-8 OS name: "linux", version: "5.4.12-200.el8_1.x86_64", arch: "amd64", family: "unix"