How to Install Java 10 on CentOS/RHEL 7/6 based System

Under this tutorial we’ll install Java 10 (18.3) on Centos/RHEL/Fedora based system, This tutorial is using alternatives command to building java which is extremely easy to use and this will configure java in seconds, the alternatives command is used for maintained symbolic links. This command used to creates, removes, maintains and displays information about the symbolic links comprising the alternatives system/app.

Lets Get Started :

STEP 1

Download, Extract and creating dir

cd /usr/local/src
wget --no-check-certificate -c --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/10.0.1+10/fb4372174a714e6b8c52526dc134031e/jdk-10.0.1_linux-x64_bin.tar.gz  

Extract the Archive file and create Java 10 dir :

cd /usr/local/src
tar zxf jdk-10.0.1_linux-x64_bin.tar.gz  
mv /usr/local/src/jdk-10.0.1 /usr/local/jdkv10

STEP 2

Installation of Java 10 :

alternatives --install /usr/bin/java java /usr/local/jdkv10/bin/java 2
alternatives --config java

Out put for alternatives –config java:-

Eg: select /usr/local/jdkv10/bin/java by typing no. 1

[root@mysterydata src]# alternatives --config java

There are 2 programs which provide 'java'.

  Selection    Command
-----------------------------------------------
   1           /usr/local/jdkv10/bin/java
*+ 2           java-1.8.0-openjdk.x86_64 (/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.171-8.b10.el7_5.x86_64/jre/bin/java)

Enter to keep the current selection[+], or type selection number: 1

It is also recommended to setup javac and jar commands path using alternatives :

alternatives --install /usr/bin/jar jar /usr/local/jdkv10/bin/jar 2
alternatives --install /usr/bin/javac javac /usr/local/jdkv10/bin/javac 2
alternatives --set jar /usr/local/jdkv10/bin/jar
alternatives --set javac /usr/local/jdkv10/bin/javac

Now Check the JAVA version :

java -version
[root@mysterydata src]# java -version
java version "10.0.1" 2018-04-17
Java(TM) SE Runtime Environment 18.3 (build 10.0.1+10)
Java HotSpot(TM) 64-Bit Server VM 18.3 (build 10.0.1+10, mixed mode)

STEP 4

Setting up Java Environment Variables :

export JAVA_HOME=/usr/local/jdkv10
export PATH=$PATH:/usr/local/jdkv10/bin

Or to load the variables automatically on OS boot use this commands :

echo "JAVA_HOME=/usr/local/jdkv10" >> /etc/environment
echo "PATH=$PATH:/usr/local/jdkv10/bin" >> /etc/environment

you’re done.

Back to top button