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: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u72-b15/jdk-8u72-linux-x64.tar.gz"

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/jdk.sh
# 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/jdk.sh
source /etc/profile.d/jdk.sh

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

-== Superman ==-

Leave a Reply

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

WordPress.com Logo

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

Google photo

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

Twitter picture

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

Facebook photo

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

Connecting to %s

%d bloggers like this: