Professional Documents
Culture Documents
Install Oracle JDK 9 On Ubuntu and Set JAVA - HOME PATH Variable
Install Oracle JDK 9 On Ubuntu and Set JAVA - HOME PATH Variable
Install Oracle JDK 9 On Ubuntu and Set JAVA - HOME PATH Variable
There are several ways we can Install JDK 9 on Ubuntu, We are going to use the
JDK 9 package provides by the Oracle.
Following are the steps you need to follow in order to install Java Development Kit
9 on Ubuntu Linux.
First step is to download the JDK installation kit from the oracle website. Go to
Oracle Java download page and download the Linux tar.gz package for Ubuntu.
https://www.configserverfirewall.com/ubuntu-linux/install-oracle-jdk-9-ubuntu/ 1/5
8/28/2021 Install Oracle JDK 9 on Ubuntu and set JAVA_HOME PATH Variable
Or From the command line you can use the wget command to download the tar.gz
file (Make sure to copy the url to the latest version from the oracle website).
After the download is finished, extract the tar file to the /opt directory.
In the /opt directory, you should see the Java installation directory. Name of the
directory should be something like "jdk-9.0.1" (Depends on the version you
downloaded).
Open /etc/bash.bashrc file in any text editor like nano, vim or gedit and add the
following lines at the end:
https://www.configserverfirewall.com/ubuntu-linux/install-oracle-jdk-9-ubuntu/ 2/5
8/28/2021 Install Oracle JDK 9 on Ubuntu and set JAVA_HOME PATH Variable
Ad removed. Details
export JAVA_HOME=/opt/jdk-9.0.1
export PATH=$PATH:$JAVA_HOME/bin
Save and source the /etc/bash.bashrc file to apply the new changes:
source /etc/bash.bashrc
We need to set Oracle JDK 9 as the default Java version in our Ubuntu Server. We
do this by using the update-alternatives command.
First add the Oracle java 9 and javac compiler to the alternatives:
(The same way you can also set other binaries including javadoc, jshell, jar and
javap)
https://www.configserverfirewall.com/ubuntu-linux/install-oracle-jdk-9-ubuntu/ 3/5
8/28/2021 Install Oracle JDK 9 on Ubuntu and set JAVA_HOME PATH Variable
Now the installation of JDK 9 is complete, we can run java and javac command
from the Ubuntu command line.
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)
javac -version
javac 9.0.1
We will run a very simple Hello world program to test our Oracle JDK 9 Installation
on Ubuntu.
First, create a file called HelloWorld.java and add following Java Code:
javac HelloWorld.java
java HelloWorld
If everything is good, the program will print following two lines to the console.
Hello World
You have successfully installed Oracle JDK 9 on Ubuntu Linux.
https://www.configserverfirewall.com/ubuntu-linux/install-oracle-jdk-9-ubuntu/ 4/5
8/28/2021 Install Oracle JDK 9 on Ubuntu and set JAVA_HOME PATH Variable
SQL Server
MySQL Administration
Unix
Debian Linux
Ubuntu Firewall
https://www.configserverfirewall.com/ubuntu-linux/install-oracle-jdk-9-ubuntu/ 5/5