This comprehensive Linux guide expects that you run the following commands as root user but if you decide to run the commands as a different user then ensure that the user has
sudo
access and that you precede each of the privileged commands withsudo
Java is one of the world’s most popular programming language. Java SE 9 is the result of an industry-wide development effort involving open review, weekly builds, and extensive collaboration between Oracle engineers and members of the worldwide Java developer community via the OpenJDK Community and the JCP.
In this tutorial, we will guide you about how to install java 9 JDK/JRE on Red-Hat Based Distributions, CentOS and Fedora.
Downloading Java 9 Binary
You can run the following commands to download the Java 9 JDK and JRE .rpm files on your system.
root@codesposts:~$ 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
root@codesposts:~$ 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
Installing Java 9 JDK/JRE
Follow the instructions below to install the Java SE 9 JDK/JRE on your system
On RHEL/CentOS and Fedora 20
To install Java 9 JDK/JRE on your RHEL/CentOS or Fedora 20, run the following commands:
root@codesposts:~$ yum install jdk-9.0.4_linux-x64_bin.rpm
root@codesposts:~$ yum install jre-9.0.4_linux-x64_bin.rpm
On Fedora 22+
To install Java 9 JDK/JRE on your Fedora 22 or higher, run the following commands:
root@codesposts:~$ dnf install jdk-9.0.4_linux-x64_bin.rpm
root@codesposts:~$ dnf install jre-9.0.4_linux-x64_bin.rpm
Setting Up Environment Variables
After installing, we need to set the environment variables and the executable files path into your system $PATH variable, by running the below commands.
Setting Up Java JDK Variables
Run the following commands to set up the Java JDK environment variables
root@codesposts:~$ export JAVA_HOME=/usr/java/jdk-9.0.4
root@codesposts:~$ export PATH=$PATH:/usr/java/jdk-9.0.4/bin
Setting Up Java JRE Variables
Run the following commands to set up the Java JRE environment variables
root@codesposts:~$ export JAVA_HOME=/usr/java/jre-9.0.4
root@codesposts:~$ export PATH=$PATH:/usr/java/jre-9.0.4/bin
Verifying The Version
You can verify the Java 9 version installed on your system by running the following command:
root@codesposts:~$ 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)
Enabling JDK/JRE Support In Firefox
To enable Java JDK/JRE support in firefox, run the following command:
root@codesposts:~$ alternatives --install /usr/lib/mozilla/plugins/libjavaplugin.so libjavaplugin.so /usr/java/jdk-9.0.4/lib/libnpjp2.so 20000