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

Spread the love

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 151 (1.8.0_151) . Here you can see also the multiple version of java also installed on server. Recently Java version 1.8 update 151 launched.

Server Support

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 151 , so we have download  1.8.0_151 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 -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

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 151 .




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_151/bin/java .Follow below command to set up.


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

Now set the jar and javac  path .


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

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

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

Check updated Java Version :


# java -version

Spread the love

Have any Question or Comment?

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

Vihag Gupta

Great! Thanks a ton!

Leave a Reply

Tech Transit Facebook Page

SuperWebTricks Loading...