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 51 on fresh installed server . Now we are going to upgrade or version from java version 1.8 update 51(1.8.0_51)  to Java version 1.8 update 60 (1.8.0_60) . Here you can see also the multiple version of java also installed on server. Recently Java version 1.8 update 60 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 version "1.8.0_51"    Java(TM) SE Runtime Environment (build 1.8.0_51-b16)    

Below are the steps to installed or upgrade java version .

Downloading Latest Java Version

Here was java launch recently update 60 , so we have download  1.8.0_60 on the server through below command . You can find latest version of java on official site page.

Run below command to download and extract the downloaded file  .

For 64 bit server : 

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

For 32 bit server : 

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

Upgrade or

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

 

#cd /opt/jdk1.8.0_60/    #alternatives --install /usr/bin/java java /opt/jdk1.8.0_60/bin/java 2    # alternatives --config java    There are 3 programs which provide 'java'.      Selection    Command    -----------------------------------------------    *  1           /usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/java     + 2           /opt/jdk1.8.0_51/bin/java       3           /opt/jdk1.8.0_60/bin/java    Enter to keep the current selection[+], or type selection number: 3    

Now set the jar and javac  path .

 

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

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

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

Check updated Java Version :

 

[[email protected] jdk1.8.0_60]# java -version    java version "1.8.0_60"    Java(TM) SE Runtime Environment (build 1.8.0_60-b27)    Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)

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

Review overview
NO COMMENTS

POST A COMMENT