Chapter 4. Selecting a system-wide archive Red Hat build of OpenJDK version
If you have multiple versions of Red Hat build of OpenJDK installed with the archive on RHEL, you can select a specific Red Hat build of OpenJDK version to use system-wide.
Prerequisites
- Know the locations of the Red Hat build of OpenJDK versions installed using the archive.
Procedure
To specify the Red Hat build of OpenJDK version to use for a single session:
Configure
JAVA_HOME
with the path to the Red Hat build of OpenJDK version you want used system-wide.$ export JAVA_HOME=/opt/jdk/jdk-11.0.9
Add
$JAVA_HOME/bin
to thePATH
environment variable.$ export PATH="$JAVA_HOME/bin:$PATH"
To specify the Red Hat build of OpenJDK version to use permanently for a single user, add these commands into ~/.bashrc
:
export JAVA_HOME=/opt/jdk/jdk-11.0.9 export PATH="$JAVA_HOME/bin:$PATH"
To specify the Red Hat build of OpenJDK version to use permanently for all users, add these commands into /etc/bashrc
:
export JAVA_HOME=/opt/jdk/jdk-11.0.9 export PATH="$JAVA_HOME/bin:$PATH"
If you do not want to redefine JAVA_HOME
, add only the PATH command to bashrc
, specifying the path to the Java binary. For example, export PATH="/opt/jdk/jdk-11.0.3/bin:$PATH"
.
Additional resources
-
Be aware of the exact meaning of
JAVA_HOME
. For more information, see Changes/Decouple system java setting from java command setting.