How To Install Oracle Java 9 & 8 (JDK) on CentOS, RHEL, Fedora, Arch Linux & openSUSE
JAVA is necessary to run Java based applications in Linux and windows machine. JAVA comes with two packages (JDK & JRE).
JDK stands for (Java Development Kit) which helps developers for developing, debugging, and monitoring Java applications.
JRE stands for (Java Runtime Environment) which deploys Java applications on servers. It included tools for JVM monitoring which commonly required for server applications.
In this article we are going to explain how to install oracle java 9 on CentOS, Fedora, openSUSE, Arch Linux & RHEL. JDK 9 reached General Availability on 21 September 2017, after a long wait. The JDK package contains JRE too, so no need to download separately. openJDK project is sponsor by oracle.
We have already covered few articles about openJDK & Oracle JAVA, hit the below link for further reading.
Download oracle java rpm file
[Download Oracle Java 9] $ sudo wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/9.0.1+11/jdk-9.0.1_linux-x64_bin.rpm" [Download Oracle Java 8 update 152] $ sudo wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u152-b16/aa0333dd3019491ca4f6ddbe78cdb6d0/jdk-8u152-linux-x64.rpm"
Install oracle java 9/8
Use the below RPM Command to Install oracle java into rpm based systems such as RHEL, CentOS, Fedora & openSUSE.
[Install Oracle Java 9] $ sudo rpm -ivh jdk-9.0.1_linux-x64_bin.rpm [Install Oracle Java 8] $ sudo rpm -ivh jdk-8u152-linux-x64.rpm
Install oracle java 9/8 on Arch Linux
Oracle java is available in AUR repository, so we can easily install on arch Linux based system without any issue using AUR helper such as Yourt or Packer.
[Install Oracle JAVA & OpenJDK] $ yaourt jdk
The above output will show you the list of available OpenJDK & Oracle JDK and JRE versions. Just type the number of your choice to get install.
Check Installed java version
Enter the following command on terminal to check the installed java version on your system.
$ java -version java version "9.0.1" Java(TM) SE Runtime Environment (build 9.0.1+11) Java HotSpot(TM) 64-Bit Server VM (build 9.0.1+11, mixed mode)
Setup JAVA Environment Variables
Make sure you have to Setup JAVA Environment Variables for java as java based applications uses environment variables to work. Open the
.bashrc file and add the below lines in end of the file and change your path instead of us, if you install through tar.gz archive file then save and exit the file.
$ nano .bashrc JAVA_HOME="/usr/java/jdk-9.0.1/bin/java" PATH=$PATH:$HOME/bin:JAVA_HOME
.bashrc file, run the following command to make it work
$ source ~/.bashrc
Now, check the environment value using below command, which clearly fetch the path of jdk home.
$ echo $JAVA_HOME /usr/java/jdk-9.0.1/bin/java