Chapter 5. Configuring the JAVA_HOME environment variable on RHEL


Some applications require you to set the JAVA_HOME environment variable so that they can find the Red Hat build of OpenJDK installation.

Prerequisites

  • You know where you installed Red Hat build of OpenJDK on your system. For example, /opt/jdk/11.

Procedure

  1. Set the value of JAVA_HOME.

    Copy to Clipboard Toggle word wrap
    $ export JAVA_HOME=/opt/jdk/11
  2. Verify that JAVA_HOME is set correctly.

    Copy to Clipboard Toggle word wrap
    $ printenv | grep JAVA_HOME
    JAVA_HOME=/opt/jdk/11
    Note

    You can make the value of JAVA_HOME persistent by exporting the environment variable in ~/.bashrc for single users or /etc/bashrc for system-wide settings. Persistent means that if you close your terminal or reboot your computer, you do not need to reset a value for the JAVA_HOME environment variable.

    The following example demonstrates using a text editor to enter commands for exporting JAVA_HOME in ~/.bashrc for a single user:

    Copy to Clipboard Toggle word wrap
    > vi ~/.bash_profile
    
    export JAVA_HOME=/opt/jdk/11
    export PATH="$JAVA_HOME/bin:$PATH"

Additional resources

Back to top
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. Explore our recent updates.

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.

Theme

© 2025 Red Hat, Inc.