Search

Chapter 4. Selecting a system-wide archive Red Hat build of OpenJDK version

download PDF

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:

  1. Configure JAVA_HOME with the path to the Red Hat build of OpenJDK version you want used system-wide.

    $ export JAVA_HOME=/opt/jdk/openjdk-17.0.0.0.35

  2. Add $JAVA_HOME/bin to the PATH 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/openjdk-17.0.0.0.35
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/openjdk-17.0.0.0.35
export PATH="$JAVA_HOME/bin:$PATH"
Note

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/openjdk-17.0.0.0.35/bin:$PATH".

Additional resources

Red Hat logoGithubRedditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

© 2024 Red Hat, Inc.