How To Install Java 9 on CentOS, Ubuntu or Debian

We show you how to download and install Java 9 on CentOS 7, Ubuntu and Linux Debian.

Many Linux operating systems have Java by default in their system and thanks to this it is possible to compile and execute development applications from multiple developers.

Java 9 features:

  • The hash of the TLS session and extended support of the master secret extension has been added
  • Additional checks of the IDL auxiliary code type are added to the method
     org.omg.CORBA.ORBstring_to_object
  • The default size of the provider key is automatically updated
  • Disabled exportable encryption suites are disabled
  • JNLP files will not start from IE11 in the creator's update of Windows 10 Creators

Now, we will see how to install Java 9 on some of the major Linux distributions.

Install Java 9 on CentOS 7

This same process applies to RedHat and Fedora. To install Java 9 in CentOS, we have two options:

1. The first is to go to the following link and there download the latest available rpm file:  JAVA 9

http://www.oracle.com/technetwork/java/javase/downloads/index.html

2. There we have the following rpm file options:

jdk-9.0.4_linux-x64_bin.rpm

jre-9.0.4_linux-x64_bin.rpm

3. In case of not using the method of downloading the rpm files, we can use the wget.

4. To 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

5. To 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

6. There we download the type of Java that we consider necessary to use.

7. Once the RPM package has been downloaded, we must go the route where it was downloaded and there execute the following line:

In RHEL, CentOS 7

yum install jdk-9.0.4_linux-x64_bin.rpm

yum install jre-9.0.4_linux-x64_bin.rpm

In Fedora 22 and higher

sudo dnf install jdk-9.0.4_linux-x64_bin.rpm

sudo dnf install jre-9.0.4_linux-x64_bin.rpm

8. In this example, we are using CentOS 7 so we run the first commands:
To install Java JDK:

yum install jdk-9.0.4_linux-x64_bin.rpm

Set the Java environment variables in CentOS 7

Next, we are going to insert the variables of Java environment and the path of the executable files in the $PATH variable of CentOS 7, this is necessary to make sure that the Java environment variables and the executables will be accessible in the whole system, for we are going to execute the following commands:

1. Set JAVA_HOME and JDK Variable Path

export JAVA_HOME=/usr/java/jdk-9.0.4

export PATH=$PATH:/usr/java/jdk-9.0.4/bin

2. Set JAVA_HOME and JRE Variable Path

export JAVA_HOME=/usr/java/jre-9.0.4

export PATH=$PATH:/usr/java/jre-9.0.4/bin

Verify Java Version in CentOS 7

1. Finally, we will check that we have Java 9 in CentOS, for this, e execute the following:

java -version

2. If we want to enable JDK/JRE support in Firefox, it will be necessary to run the following commands for its allowing:

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

Install Java 9 using PPA repositories in Debian

For this, we have two options, and the first is using repositories.

1. To add this unofficial repository in Debian 9, we will execute the following line:

sudo add-apt-repository ppa:webupd8team/java

2. Proceed to update the repository by running the following:

sudo apt-get update

3. As soon as the PPA has been added and updated, we should look for the packages with the name oracle-java9 in the following way:

apt-cache search oracle-java9

4. This result confirms that Java 9 is available to install through the following command:

apt-get install oracle-java9-installer

5. Accept the terms of the Oracle license.

6. In case of having more than one Java installed in Debian, we can install the oracle-java9-set-default package to set Java 9 by default:

sudo apt-get install oracle-java9-set-default

Install Java 9 using the source in Debian

Another alternative to install Java 9 is to download from the following link the respective Java 9 SE SDK file:  JAVA 9 SDK

http://www.oracle.com/technetwork/java/javase/downloads/jdk9-downloads-3848520.html

1. There we must accept the license agreement to start the process of downloading the latest version of the tarball package.

Java does not offer pre-compiled packages in the form of .deb packages for Linux distributions based on Debian, so we must use the compressed gzip file to perform this installation.

Now, as an alternative, we can download this file using the wget command in the following way:

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.tar.gz

2. Go to the path where Java was installed, and we will execute the following commands which will decompress the Java tarball file directly in the /opt directory, then we will enter the java extracted path from the /opt directory and execute the ls command to show the contents of the directory. The executable Java files are in the bin directory:

sudo tar xfz jdk-9.0.4_linux-x64_bin.tar.gz -C /opt/

cd /opt/jdk-9.0.4/

ls

3. Finally, e will export the Java variables by executing:

sudo echo 'export JAVA_HOME=/opt/jdk-9.0.4/' | sudo tee /etc/profile.d/java.sh

sudo echo 'export PATH=$PATH:/opt/jdk-9.0.4/bin' | sudo tee -a /etc/profile.d/java.sh

4. In both cases, to know the Java version we will run the following command:

java –version

 

Install Java 9 on Ubuntu 17

The same commands that we have used in Debian 9 are useful for the installation of Java 9 in Ubuntu 17.

1. In this case, the first option is to use a PPA repository using the following commands:

sudo add-apt-repository ppa:webupd8team/java

sudo apt-get update

sudo apt-get install oracle-java9-installer

sudo apt-get install oracle-java9-set-default

2. But in this case, we are going to use the second method that is to download the file directly from the official site

3. Or we can use the wget command like this:

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.tar.gz

4. After Java 9 is downloaded, we will go to the directory where it was downloaded, and there we will execute the following commands to install Java:

sudo tar xfz jdk-9.0.4_linux-x64_bin.tar.gz -C /opt/

cd /opt/jdk-9.0.4/

ls

5. These commands will uncompress the Java tarball file directly in the / opt directory; we will enter the path where the Java content was extracted from the / opt directory, and we will execute the ls command to show the contents of the directory.

6. Java executables are in the bin directory.

7. The next step is to insert the Java environment variables and the path of the executable files in the $ PATH variable of the system, for this we will use the following commands:

sudo echo 'export JAVA_HOME=/opt/jdk-9.0.4/' | sudo tee /etc/profile.d/java.sh

sudo echo 'export PATH=$PATH:/opt/jdk-9.0.4/bin' | sudo tee -a /etc/profile.d/java.sh

8. Finally, we can validate the Java 9 version using the following command:

java - version

In this way, we have learned to install Java 9 in some of the most used Linux distributions.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *