Skip to content

Java Installation – Centos 7.x

Step-1: Environment

Centos 7.x 64bit VM
Google Cloud Platform
Binary installation

Step-2: Download Binaries

$ cd /opt
$ sudo 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/8u141-b15/336fa29ff2bb4ef291e347e091f7f4a7/jdk-8u141-linux-x64.tar.gz"

Step-3: Extract the Binaries

$ sudo tar xzf jdk-8u141-linux-x64.tar.gz

Step-4: Install using alternatives

$ cd /opt/jdk1.8.0_141

$ sudo alternatives --install /usr/bin/java java /opt/jdk1.8.0_141/bin/java 2;
$ sudo alternatives --install /usr/bin/jar jar /opt/jdk1.8.0_141/bin/jar 2;
$ sudo alternatives --install /usr/bin/javac javac /opt/jdk1.8.0_141/bin/javac 2;
$ sudo alternatives --set jar /opt/jdk1.8.0_141/bin/jar;
$ sudo alternatives --set javac /opt/jdk1.8.0_141/bin/javac;

Step-5: Check the installation

$ java -version

java version "1.8.0_144"
java(TM) SE Runtime Environment (build 1.8.0_144-b01)
java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)

Step-6: Setting Environmental Variables

$ sudo vi /etc/profile.d/java.sh

#!bin/sh
JAVA_HOME=/opt/jdk1.8.0_141/
JRE_HOME=/opt/jdk1.8.0_141/jre
export PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
CLASSPATH=.

$ sudo chmod +x java.sh
$ source /etc/profile.d/java.sh

Shashi View All

-== Superman ==-

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: