How to Install Oracle Java on CentOS/RHEL

A quick introduction -
Java is a common and popular software platform that let’s you run Java applications and applets.
You can find three different variations of Java Platform on the official website - Standard Edition (SE), Enterprise Edition (EE) and Micro Edition (ME). We will be using SE in this tutorial.


Now even the Java SE Platform has two different packages that can be installed - Java Runtime Environment (JRE) and Java Development KIt (JDK).
JRE - This is used to run the compiled Java applications.
JDK - As the name suggests, it is used for writing, developing/building and compiling the Java applications.
We will be covering both the installations.


  1. Installation of Oracle Java 8 JRE

Step 1.1 -
First we will go to the official Site - Official Oracle Java 8 JRE Downloads Page and download the correct .rpm package using the wget command.

Note: You can choose any other version too, according to your requirements, just copy the respective download link and replace it in the below command.


wget --no-cookies --no-check-certificate --header "Cookie:  gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie"
“http://download.oracle.com/otn-pub/java/jdk/8u102-b14/jre-8u102-linux-x64.rpm”

Step 1.2 -

Now we need to install the rpm package.


sudo yum localinstall jre-8u102-linux-x64.rpm
After this, Java should be installed at /usr/java/jre1.8.0_102/bin/java
Java 8 JRE Installation is done!

2. Installation of Oracle Java 8 JDK
Step 2.1 -
First we will go to the official Site - Official Oracle Java 8 JDK Downloads Page and download the correct .rpm package using the wget command.
Note: You can choose any other version too, according to your requirements, just copy the respective download link and replace it in the below command.


wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" “http://download.oracle.com/otn-pub/java/jdk/8u102-b14/jdk-8u102-linux-x64.rpm”
Step 2.2 -
Now we need to install this rpm package.
Java should be installed at /usr/java/jdk1.8.0_102/bin/java
Java 8 JDK Installation is done!

3. Using the alternatives command
The alternatives command can be used to set the default java to be used.


No comments:

Post a Comment