Java 10 non-LTS release is now available for the installation. As per the new numbering opted by the Java team, This is also known as Java 18.03. This version will be supported for the next 6 months. This tutorial helps you to install Java 18.03 on a Fedora and CentOS/RHEL systems.
Step 1 – Download Java 10
Use the following command to download JDK 10 from Oracle official site. You can also visit official download page for the latest version if available.
wget --no-cookies --no-check-certificate --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
Now extract the archive under /usr/local directory.
tar zxf jdk-10.0.1_linux-x64_bin.tar.gz -C /usr/local mv /usr/local/jdk-10.0.1 /usr/local/jdk-10
Step 2 – Install Java 10
After extracting the archive file use alternatives command to configure Java on Linux system. The alternatives command is available in chkconfig package.
alternatives --install /usr/bin/java java /usr/local/jdk-10/bin/java 2 alternatives --config java There are 2 programs that provide 'java'. Selection Command ----------------------------------------------- *+ 1 /usr/local/jdk-9.0.4/bin/java 2 /usr/local/jdk-10/bin/java Enter to keep the current selection[+], or type selection number: 2
At this point Java 10 has been successfully installed on your system. We also recommend to setup javac and jar commands path using alternatives
alternatives --install /usr/bin/jarjar /usr/local/jdk-10/bin/jar 2 alternatives --install /usr/bin/javacjavac /usr/local/jdk-10/bin/javac 2 alternatives --set jar/usr/local/jdk-10/bin/jar alternatives --set javac/usr/local/jdk-10/bin/javac
Step 3 – Check Active Java Version
Check the installed Java version on your system using the following command.
java -version java 10 2018-03-20 Java(TM) SE Runtime Environment 18.3 (build 10+46) Java HotSpot(TM) 64-Bit Server VM 18.3 (build 10+46, mixed mode)
Step 4 – Setup Java Environment Variables
Most of the Java-based applications uses environment variables to work. Set the Java environment variables using following commands
- Setup JAVA_HOME Variable
export JAVA_HOME=/usr/local/jdk-10 export PATH=$PATH:/usr/local/jdk-10/bin
Also put all above environment variables in /etc/environment file for auto loading on system boot.