Install Java 8 ( JDK 8u151 ) on RHEL 7 /CentOS 7 and Fedora

Spread the love

This article explain you how to install and configure Java  JDK latest version  on CentOS /RHEL servers. Here I am going to install latest Java JDK on  CentOS 7  Version . Below is my CentOS Server information.
[[email protected]~]# cat /etc/redhat-release
CentOS Linux release 7.3.1611 (Core)

Downlod Java  JDK   Latest Version

Download  latest  Java SE  Development Kit  8  from  official Java vendor . Below are the steps for download the java  and extract in temporary folder in linux.
For  Linux x64 ( 64 Bit )
# cd /tmp
# curl -LO -H --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie"
# tar xzf jdk-8u151-linux-x64.tar.gz
# mv jdk1.8.0_151 /opt

For  Linux x86 ( 32 Bit )
# cd /tmp
# curl -LO -H --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie"
# tar xzf jdk-8u151-linux-i586.tar.gz
# mv jdk1.8.0_151 /opt

Here we have –no-cookies and  –header option with  curl or wget because of oracle does not give download unless we have not accept their license or terms .for accept header and license use above syntax for download .

Server Support
–no-cookies –header “Cookie: oraclelicense=accept-securebackup-cookie”

Install  Java

Now we have got extracted folder of java (jdk1.8.0_71). Alternatives command is the best way to install java. Go to the extracted folder of java and run like below command as showing.
# cd /opt/jdk1.8.0_151
# alternatives --install /usr/bin/java java /opt/jdk1.8.0_151/bin/java 2

Now  we should set  jar and javac  path .
# alternatives --install /usr/bin/jar jar /opt/jdk1.8.0_151/bin/jar 2
# alternatives --install /usr/bin/javac javac /opt/jdk1.8.0_151/bin/javac 2
# alternatives --set jar /opt/jdk1.8.0_151/bin/jar
# alternatives --set javac /opt/jdk1.8.0_151/bin/javac

Set  Java Environment Variables :

After the set of javac and jre path , we will set the environment variables  in linux . So many application needs to use the JAVA_Home or JRE_HOME environment variables for java executable to use, even you can not  see java version without environment  variables set.

To set  java home variable use below command.

# export JAVA_HOME=/opt/jdk1.8.0_151

To set  jre home variable use below command

# export JRE_HOME=/opt/jdk1.8.0_151/jre/

To set the path variables use below command

# export PATH=$PATH:/opt/jdk1.8.0_151/bin:/opt/jdk1.8.0_151/jre/bin

Verify Installed Java Version

Now check the version of installed java on linux box through below command
# java -version
java version "1.8.0_151"
Java(TM) SE Runtime Environment (build 1.8.0_151-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.151-b12, mixed mode)

If your java command not running after set the environment variables then add below lines  in bashrc and profile files in /etc directory.

export PATH=$JAVA_HOME/bin:$PATH
Congratulations, Now we have install , run and configure java !


Spread the love

Tech Transit Facebook Page

SuperWebTricks Loading...