How To Install Java On RHEL 8: RedHat Tutorial

How To Install Java On RHEL 8: RedHat Tutorial
Written by itsubuntu

Last Updated on

Insight: How To Install Java On RHEL 8

In this simple tutorial, we are going to show you the method to install Java on RHEL 8.

How To Install Java On RHEL 8 : RedHat Tutorial

You can either install OpenJDK or Oracle Java. It’s up to your requirement.

Install OpenJDK JDK:

yum -y install java-1.8.0-openjdk-devel
yum -y install java-11-openjdk-devel

Install OpenJDK JRE:

yum -y install java-1.8.0-openjdk
yum -y install java-11-openjdk

Install Oracle Java:

Run the following command if you want  to install it via command line procedure:

yum install -y wget
wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie"


Install Oracle Java JDK using rpm command:

rpm -ivh jdk-12.0.1_linux-x64_bin.rpm
rpm -ivh jdk-11.0.3_linux-x64_bin.rpm
rpm -ivh jdk-8u211-linux-x64.rpm

Run the following command to set default java version in RHEL 8:

alternatives --config java


Setup Environmental Variables In RHEL 8

At first, create a new file under /etc/profile.d directory:

vi /etc/profile.d/


Set variables on the basis of java version:

export PATH=$PATH:/usr/lib/jvm/java-11-openjdk-
export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-
export J2SDKDIR=/usr/lib/jvm/java-11-openjdk-

Now you need to load the environments into the current sessions:

source /etc/profile.d/

About the author


Subscribe To Our Newsletter

Subscribe To Our Newsletter

Dear lovely people, Welcome to

Join our mailing list to receive the freebies, tutorials, latest news and updates from our team.

You have Successfully Subscribed!