CentOSLinuxTutorials

How To Install Oracle JDK 9 on CentOS 7

Install Oracle JDK 9 on CentOS 7

In this tutorial, we will show you how to install and configuration of Oracle JDK 9 on your CentOS 7. There are many programs and scripts that require java to run, but usually, Java is not installed by default on VPS or Dedicated Server.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo’ to the commands to get root privileges. I will show you the step-by-step installation of Oracle JDK 9 on a CentOS 7 server.

Prerequisites

  • A server running one of the following operating systems: CentOS 7.
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • SSH access to the server (or just open Terminal if you’re on a desktop).
  • A non-root sudo user or access to the root user. We recommend acting as a non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.

Install Oracle JDK 9 on CentOS 7

Step 1. First, remove the Java 1.6 or 1.7 that have been installed already, you can uninstall them using the following commands.

yum remove java-1.6.0-openjdk
yum remove java-1.7.0-openjdk

Step 2. Downloading and Installing Oracle JDK 9 on CentOS 7.

First, go to the Java 9 official website of Oracle, select the appropriate version and then download:

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

Next, change the directory to the location where you want to install the JDK, then move the .tar.gz archive binary to the current directory:

tar zxf jdk-9.0.4_linux-x64_bin.tar.gz -C /usr/local

Step 3. Install JAVA using alternatives.

After extracting the archive file use the alternatives command to install it. alternatives command is available in chkconfig the package:

cd /usr/local/jdk-9.0.4/
alternatives --install /usr/bin/java java /usr/local/jdk-9.0.4/bin/java 2
alternatives --config java


There is 1 program that provides 'java'.

Selection Command
-----------------------------------------------
*+ 1 /usr/local/jdk-9.0.4/bin/java

Enter to keep the current selection[+], or type selection number: 1

At this point, JAVA 9 has been successfully installed on your system. We also recommend to set up the javac and jar commands path using alternatives:

alternatives --install /usr/bin/jar jar /usr/local/jdk-9.0.4/bin/jar 2
alternatives --install /usr/bin/javac javac /usr/local/jdk-9.0.4/bin/javac 2
alternatives --set jar /usr/local/jdk-9.0.4/bin/jar
alternatives --set javac /usr/local/jdk-9.0.4/bin/javac

Step 4. Checking Installed java version.

root@idroot.us ~# java -version
java version "9.0.4"
Java(TM) SE Runtime Environment (build 9+181)
Java HotSpot(TM) 64-Bit Server VM (build 9+181, mixed mode)

Step 5. Setup global environment variables.

We can easily set the environment variables using the export command as shown below:

Setup JAVA_HOME Variable:

export JAVA_HOME=/usr/local/jdk-9.0.4

Setup JRE_HOME Variable:

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

Congratulations! You have successfully installed Oracle JDK 9. Thanks for using this tutorial for installing Oracle JDK 9 on CentOS 7 systems. For additional help or useful information, we recommend you check the official Oracle website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

Save

r00t

r00t is a seasoned Linux system administrator with a wealth of experience in the field. Known for his contributions to idroot.us, r00t has authored numerous tutorials and guides, helping users navigate the complexities of Linux systems. His expertise spans across various Linux distributions, including Ubuntu, CentOS, and Debian. r00t's work is characterized by his ability to simplify complex concepts, making Linux more accessible to users of all skill levels. His dedication to the Linux community and his commitment to sharing knowledge makes him a respected figure in the field.
Back to top button