Skip to content

Install Java 8 on CentOS

Update the cache and install basic tools

sudo su -
yum update
yum install wget lsof -y

Download Java SE Development Kit 8 release

cd /opt/
wget --no-cookies --no-check-certificate --header "Cookie:; oraclelicense=accept-securebackup-cookie" ""

Extract the archive

tar xzf jdk-8u72-linux-x64.tar.gz

Install Java with Alternatives

cd /opt/jdk1.8.0_72/

alternatives --install /usr/bin/jar jar /opt/jdk1.8.0_72/bin/jar 2
alternatives --install /usr/bin/javac javac /opt/jdk1.8.0_72/bin/javac 2
alternatives --set jar /opt/jdk1.8.0_72/bin/jar
alternatives --set javac /opt/jdk1.8.0_72/bin/javac

Configuring Environment Variables

vim /etc/profile.d/
# Setup JAVA_HOME Variable
export JAVA_HOME=/opt/jdk1.8.0_72
# Setup JRE_HOME Variable
export JRE_HOME=/opt/jdk1.8.0_72/jre
# Setup PATH Variable
export PATH=$PATH:/opt/jdk1.8.0_72/bin:/opt/jdk1.8.0_72/jre/bin

Make sure the ENV variable are available after reboot

chmod +x /etc/profile.d/
source /etc/profile.d/

Checked Installed Java Version

java -version

java version "1.8.0_72"
Java(TM) SE Runtime Environment (build 1.8.0_72-b15)
Java HotSpot(TM) 64-Bit Server VM (build 25.72-b15, mixed mode)

Shashi View All

A passionate devops and automation engineer

One thought on “Install Java 8 on CentOS Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: