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:; oraclelicense=accept-securebackup-cookie" ""
tar xzf jdk-8u121-linux-i586.tar.gz

64bit OS

cd /opt/
wget --no-cookies --no-check-certificate --header "Cookie:; oraclelicense=accept-securebackup-cookie" ""
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
ONET IDC thành lập vào năm 2012, là công ty chuyên nghiệp tại Việt Nam trong lĩnh vực cung cấp dịch vụ Hosting, VPS, máy chủ vật lý, dịch vụ Firewall Anti DDoS, SSL… Với 10 năm xây dựng và phát triển, ứng dụng nhiều công nghệ hiện đại, ONET IDC đã giúp hàng ngàn khách hàng tin tưởng lựa chọn, mang lại sự ổn định tuyệt đối cho website của khách hàng để thúc đẩy việc kinh doanh đạt được hiệu quả và thành công.
Bài viết liên quan

How to Upgrade from RHEL 7 to RHEL 8

Long waited Red Hat Enterprise Linux 8 (RHEL 8) was released recently. One of the ways of getting RHEL 8 is to download...

Oracle Linux vs RedHat

Oracle and Red Hat are big names in the world of enterprise Linux. With more similarities than differences, the choice between...

Install Google Chrome on RHEL8

This tutorial explains how to install Google Chrome with 2 commands only (wget and yum install) as an introduction to packages...