Home / Linux  / Install and Upgrade Java Version on CentOs ,Red Hat and Fedora Linux

Install and Upgrade Java Version on CentOs ,Red Hat and Fedora Linux

update java redhat Linux Java install java Fedora Centos

When the server OS installed on server or system, most of the time version is not updated and also some time we need to update or upgrade version on server. Earlier in our article we have install Java version 8  update 111 on fresh installed server . Now we are going to upgrade or version from java version 1.8 update 111(1.8.0_111)  to Java version 1.8 update 121 (1.8.0_121) . Here you can see also the multiple version of java also installed on server. Recently Java version 1.8 update 121 launched.

Below is my java version , I ran the command to check java version java -version, Now here is output of my 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)    

Below are the steps to installed or upgrade java version .

Downloading Latest Java Version

Here was java launch recently update 121 , so we have download  1.8.0_121 on the server through below command . You can find latest version of java on official site page.Download  latest  Java SE  Development Kit  8  from  official Java vendor .

Run below command to download and extract the downloaded file  .

For  x64 ( 64 Bit )

# cd /tmp
# curl -LO http://download.oracle.com/otn-pub/java/jdk/8u121-b13/e9e7ea248e2c4826b92b3f075a80e441/jdk-8u121-linux-x64.tar.gz -H --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie"
# tar -xzf jdk-8u121-linux-x64.tar.gz
# mv jdk1.8.0_121/ /opt

For  Linux x86 ( 32 Bit )

# cd /tmp
# curl -LO http://download.oracle.com/otn-pub/java/jdk/8u121-b13/e9e7ea248e2c4826b92b3f075a80e441/jdk-8u121-linux-i586.tar.gz  -H --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie"
# tar xzf jdk-8u121-linux-i586.tar.gz
# mv jdk1.8.0_121 /opt

As we have earlier discussed in other articles that  –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 .


Installation of Java 8 on 7 :

You can find installation of Java on fresh linux system  through this link  install Java version 8  update 111 .




Update Java

Now go to the java extracted folder through below command and install or switch to java version through alternatives command. This is the best way to install or switch java version to other. When we run the alternatives –config java , the command output will show different java programs which provide java, We need to choose or select command.Here we have selected /opt/jdk1.8.0_121/bin/java .Follow below command to set up.


# cd /opt/jdk1.8.0_121/
# alternatives --install /usr/bin/java java /opt/jdk1.8.0_121/bin/java 2
# alternatives --config java

Now set the jar and javac  path .


[[email protected] jdk1.8.0_121]# alternatives --install /usr/bin/jar jar /opt/jdk1.8.0_121/bin/jar 2
[[email protected] jdk1.8.0_121]# alternatives --install /usr/bin/javac javac /opt/jdk1.8.0_121/bin/javac 2
[[email protected] jdk1.8.0_121]# alternatives --set jar /opt/jdk1.8.0_121/bin/jar
[[email protected] jdk1.8.0_121] # alternatives --set javac /opt/jdk1.8.0_121/bin/javac

Now set the Environment Variables path of Java,Jre  home variable  through below commands

 # export JAVA_HOME=/opt/jdk1.8.0_121
# export JRE_HOME=/opt/jdk1.8.0_121/jre/
#export PATH=$PATH:/opt/jdk1.8.0_121/bin:/opt/jdk1.8.0_121/jre/bin

Check updated Java Version :


# java -version






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

Review overview
  • zan January 10, 2017

    Thank you, it helps !

  • Vihag Gupta January 14, 2017

    Great! Thanks a ton!


Time limit is exhausted. Please reload CAPTCHA.