Home / Linux  / Install Java 8 ( JDK 8u111) on RHEL 7 /CentOS 7 and Fedora

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

redhat Linux Java install java Fedora Centos

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.2.1511 (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 http://download.oracle.com/otn-pub/java/jdk/8u111-b14/jdk-8u111-linux-x64.tar.gz -H --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie"
# tar xzf jdk-8u111-linux-x64.tar.gz
# mv jdk1.8.0_111 /opt

For  Linux x86 ( 32 Bit )

#cd /tmp
# curl -LO http://download.oracle.com/otn-pub/java/jdk/8u111-b14/jdk-8u111-linux-i586.tar.gz  -H --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie"
#tar xzf jdk-8u111-linux-i586.tar.gz
# mv jdk1.8.0_111 /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 .

–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_111
# alternatives --install /usr/bin/java java /opt/jdk1.8.0_111/bin/java 2

Now  we should set  jar and javac  path .

# alternatives --install /usr/bin/jar jar /opt/jdk1.8.0_111/bin/jar 2
# alternatives --install /usr/bin/javac javac /opt/jdk1.8.0_111/bin/javac 2
 # alternatives --set jar /opt/jdk1.8.0_111/bin/jar
 # alternatives --set javac /opt/jdk1.8.0_111/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_111

To set  jre home variable use below command

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

To set the path variables use below command

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

Verify Installed Java Version

Now check the version of installed java on linux box through below command

[[email protected]]# java -version
Java(TM) SE Runtime Environment (build 1.8.0_111-b14)  Java HotSpot(TM) 64-Bit Server VM (build 25.111-b14, 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.

JAVA_HOME=/opt/jdk1.8.0_111/    export PATH=$JAVA_HOME/bin:$PATH


Congratulations, Now we have install , run and configure java !


A Linux Geek with Freelance Contributor, Server/ Cloud Administrator having experience in Open Source and Cloud Technologies.

Review overview

Sorry, the comment form is closed at this time.