Installing Oracle JRE or JDK 8 on RHEL-based Systems

Steps for installing Oracle JDK 8 on RHEL-based systems.

Configure your system to use the latest version of Oracle Java SE 8 JRE or JDK (1.8u151minimum). Java 9 and later are not supported.
Note: After installing the JDK, you may need to set JAVA_HOME to your profile:
  • For shell or bash: export JAVA_HOME=path_to_java_home
  • For csh (C shell): setenv JAVA_HOME=path_to_java_home

  1. Check which version of the JDK your system is using:
    java -version
    If the OpenJDK is used, the results should look like:
    openjdk version "1.8.0_242"
    OpenJDK Runtime Environment (build 1.8.0_242-b09)
    OpenJDK 64-Bit Server VM (build 25.242-b09, mixed mode)
    If Oracle Java is used, the results should look like:
    java version "1.8.0_241"
    Java(TM) SE Runtime Environment (build 1.8.0_241-b07)
    Java HotSpot(TM) 64-Bit Server VM (build 25.241-b07, mixed mode)
  2. If necessary, go to Oracle Java SE Downloads, accept the license agreement, and download the installer for your distribution.

    The Oracle JDK License has changed for releases starting April 16, 2019. See Java SE Development Kit 8 Downloads.

    Note: If installing the Oracle JDK in a cloud environment, download the installer to your local client, and then use scp (secure copy) to transfer the file to your cloud machines.
  3. Update the repositories:
    sudo update yum
  4. From the directory where you downloaded the package, run the install:
    sudo rpm -ivh jdk-8uversion-linux-x64.rpm

    The RPM installs the JDK into the /usr/java/ directory.

  5. Use the alternatives command to add a symbolic link to the Oracle JDK installation so that your system uses the Oracle JDK instead of the OpenJDK:
    sudo alternatives --install /usr/bin/java java /usr/java/jdk1.8.0_version/bin/java 200000
    If you have any problems, set the PATH and JAVA_HOME variables:
    export PATH="$PATH:/usr/java/latest/bin"
    set JAVA_HOME=/usr/java/latest
  6. Verify the version of the JRE or JDK:
    java -version
    java version "1.8.0_241"
    Java(TM) SE Runtime Environment (build 1.8.0_241-b07)
    Java HotSpot(TM) 64-Bit Server VM (build 25.241-b07, mixed mode)
  7. If the OpenJDK is still being used, use the alternatives command to switch it. For example:
    sudo alternatives --config java