How to install Java 8u121 (JDK/JRE) on CentOS, RHEL

How to install Java 8u121 (JDK/JRE) on CentOS, RHEL

Java 8u121 recently released, is a programming language and computing platform that is used by lots of applications and websites. It is fast, secure, as well as reliable. Java JDK (Java SE Development Kit) is for developers and it includes a complete JRE plus tools for developing, debugging, as well as monitoring Java applications. Java JRE (Java Runtime Environment) is mostly for end-users, and it contains everything required to run Java applications on your system.

The most recent update Java 8u121 includes important security fixes. See release notes for full details

In this tutorial, we will show you how to install the latest Java 8u121 update on CentOS 7 with a few command lines.

 Java 8u121

How to install Java 8u121 JDK/JRE on CentOS 7

  • Download and extract the latest update package

32bit OS

cd /opt/
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/8u121-b13/e9e7ea248e2c4826b92b3f075a80e441/jdk-8u121-linux-i586.tar.gz"
tar xzf jdk-8u121-linux-i586.tar.gz

64bit OS

cd /opt/
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/8u121-b13/e9e7ea248e2c4826b92b3f075a80e441/jdk-8u121-linux-x64.tar.gz"
tar xzf jdk-8u121-linux-x64.tar.gz
  • Change folder ownership
sudo chown -R root: jdk1.8.0_*
  • Now install Java using the ‘alternatives’ command
sudo alternatives --install /usr/bin/java java /opt/jdk1.8.0_121/bin/java 1
alternatives --config java
  • Also recommended to setup javac and jar paths
----- For JAR -----
alternatives --install /usr/bin/jar jar /opt/jdk1.8.0_121/bin/jar 1
alternatives --set jar /opt/jdk1.8.0_121/bin/jar

----- For JAVAC -----
alternatives --install /usr/bin/javac javac /opt/jdk1.8.0_121/bin/javac 2xx
alternatives --set javac /opt/jdk1.8.0_121/bin/javac
  • Remove the downloaded package file
sudo rm /opt/jdk-8u121*.tar.gz
  • Next set the Environment Variables
----- For JAVA_HOME -----
export JAVA_HOME=/opt/jdk1.8.0_121

----- For JRE_HOME -----
export JRE_HOME=/opt/jdk1.8.0_121/jre

----- For PATH -----
export PATH=$PATH:/opt/jdk1.8.0_121/bin:/opt/jdk1.8.0_121/jre/bin
  • Check installed Java version
java -version
Related Posts