Install Java 9 JDK/JRE on RHEL/CentOS 7/6 and Fedora 27-20

Most of the Linux operating systems comes with pre-installed OpenJDK package to run java-based applications and plugins. Now, you’re thinking if Java already ships with OS, why we need to install it again?. Yes!...

Most of the Linux operating systems comes with pre-installed OpenJDK package to run java-based applications and plugins. Now, you’re thinking if Java already ships with OS, why we need to install it again?. Yes! good question, but in certain cases we need Sun/Oracle Java program to compile and run particular development applications.

This is the reason, in this article we will cover the installation process of Java 9 Standard Edition Development Kit (JDK) and Java SE Runtime Environment (JRE) via binary packages in RHEL 7.x/6.x, CentOS 7.x/6.x and Fedora 27-20 systems using binary RPM files.

Downloading Java JDK / JRE 9 Binary

To install Java 9 in RHEL or CentOS based Desktop machine, open a browser and navigate to Java SE official download page and grab the latest .rpm binary package in your system.

For reference, we have provided the rpm file-names, please select these below mentioned files only.

jdk-9.0.4_linux-x64_bin.rpm
jre-9.0.4_linux-x64_bin.rpm


Alternatively, you may use wget utility to download Java 9 RPM packages by issuing the below commands.

-------- Download Java SE JDK -------- # wget --no-cookies --no-check-certificate --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/9.0.4+11/c2514751926b4512b076cc82f959763f/jdk-9.0.4_linux-x64_bin.rpm
-------- Download Java SE JRE --------
# wget --no-cookies --no-check-certificate --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/9.0.4+11/c2514751926b4512b076cc82f959763f/jre-9.0.4_linux-x64_bin.rpm

Install Java JDK / JRE 9

After Java .rpm file download completes, navigate to the directory where Java package has been downloaded and install Java JDK/JRE by issuing the below command. Answer with “y” (yes) when prompted in order to accept the package installation process made by system installer.

-------- On RHEL/CentOS 7/6 and Fedora -------- # yum install jdk-9.0.4_linux-x64_bin.rpm
# yum install jre-9.0.4_linux-x64_bin.rpm
-------- On Fedora 22+ Release -------- $ sudo dnf install jdk-9.0.4_linux-x64_bin.rpm
$ sudo dnf install jre-9.0.4_linux-x64_bin.rpm

Setup Java Environment Variables

Next, insert Java environment variables and the executable files path into your system $PATH variable, by issuing the below commands. This method ensures that Java environment variables and executables will be accessible system-wide.

-------- Set JAVA_HOME and Path Variable JDK -------- # export JAVA_HOME=/usr/java/jdk-9.0.4
# export PATH=$PATH:/usr/java/jdk-9.0.4/bin
-------- Set JAVA_HOME and Path Variable JRE --------
# export JAVA_HOME=/usr/java/jre-9.0.4
# export PATH=$PATH:/usr/java/jre-9.0.4/bin

Check Java JDK / JRE 9 Version

Finally, after Java has been installed, open a terminal and issue the below command to verify Java installed version in your system.

# java --version
java 9.0.4
Java(TM) SE Runtime Environment (build 9.0.4+11)
Java HotSpot(TM) 64-Bit Server VM (build 9.0.4+11, mixed mode)

Enable Java JDK / JRE 9 Support in Firefox

To enable JDK /JRE support in Firefox we need to run the following commands to enable it. If you don’t have Firefox installed and like to install it, then check Install Latest Firefox in Linux guide.

# alternatives --install /usr/lib/mozilla/plugins/libjavaplugin.so libjavaplugin.so /usr/java/jdk-9.0.4/lib/libnpjp2.so 20000

Verify it, by restarting Firefox and enter about:plugins on the address bar.

Read Also: Install Java 8 JDK 8u45 in Debian and Ubuntu

Congratulations! You’ve successfully installed the latest version of Java 9 SE SDK in CentOS/RHEL based Linux systems.

Posted by wiredgorilla