How To Install Java On RHEL 8: RedHat Tutorial

How To Install Java On RHEL 8: RedHat Tutorial

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" https://download.oracle.com/otn-pub/java/jdk/12.0.1+12/69cfe15208a647278a19ef0990eea691/jdk-12.0.1_linux-x64_bin.rpm

 

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/java.sh

 

Set variables on the basis of java version:

export PATH=$PATH:/usr/lib/jvm/java-11-openjdk-11.0.2.7-2.el8.x86_64/bin/
export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-11.0.2.7-2.el8.x86_64/
export J2SDKDIR=/usr/lib/jvm/java-11-openjdk-11.0.2.7-2.el8.x86_64/

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

source /etc/profile.d/java.sh
READ More Relevant Stuff:  200+ Free Linux Ebooks Collection For Lifetime

Comments

No comments yet. Why don’t you start the discussion?

    Leave a Reply

    Your email address will not be published. Required fields are marked *