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

When the server OS installed on server or system, most of the time version is not updated or not installed on operating system and also some time we need to update or upgrade java version on server. Earlier in our article we had version 11 on fresh installed server . Now we are going to upgrade or version from java version 11 ( openjdk 11 )  to Java version 13 ( openjdk 13.0.2 ) . Here you can see also the multiple version of java also installed on server. Recently Java version 14 also 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
openjdk 11 2018-09-25
OpenJDK Runtime Environment 18.9 (build 11+28)
OpenJDK 64-Bit Server VM 18.9 (build 11+28, mixed mode)

Below are the steps to installed or upgrade java version .

Downloading Latest Java 13 Version

Here was java launch recently update openjdk 13.0.2 , so we have download  on the server through below command . You can latest version of java on official site page. Oracle also provides the latest OpenJDK release at under the GPL License .

Run below command to download and extract the downloaded file  .

x64 Java Development Kit 

 # cd /tmp
# wget
#  tar xvf openjdk-13.0.2_linux-x64_bin.tar.gz
# mv jdk-11 /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 13

Update Java

Now go to the java extracted folder through below command and 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/jdk-13.0.2/bin/java .Follow below command to set up.

# cd /opt/jdk-13.0.2
# alternatives --install /usr/bin/java java /opt/jdk-13.0.2/bin/java 2
# alternatives --config java
Select Java Version

Now set the jar and javac  path .

# alternatives --install /usr/bin/jar jar /opt/jdk-13.0.2/bin/jar 2
# alternatives --install /usr/bin/javac javac /opt/jdk-13.0.2/bin/javac 2
# alternatives --set jar /opt/jdk-13.0.2/bin/jar
# alternatives --set javac /opt/jdk-13.0.2/bin/javac

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

# export JAVA_HOME=/opt/jdk-13.0.2/
# export JRE_HOME=/opt/jdk-13.0.2/jre

Check updated Java Version :

[[email protected]]# java --version
openjdk 13.0.2 2020-01-14
OpenJDK Runtime Environment (build 13.0.2+8)
OpenJDK 64-Bit Server VM (build 13.0.2+8, mixed mode, sharing)

About Sachin Gupta

I am a professional freelance contributor and founder of tech transit. Love to write and lover of education, culture, and community. I have been using it, setting, supporting, and maintaining it since 2009.Linux rocks!

Have any Question or Comment?

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


Thank you, it helps !

Vihag Gupta

Great! Thanks a ton!


Leave a Reply

Your email address will not be published.