Install oracle java 9 in Ubuntu or Linux (JDK 9)

500x328_java_9-1In this tutorial we will look at how to install Java 9 in your Ubuntu or Linux environment. Oracle Java PPA for Ubuntu and LinuxMint is being maintained by Webupd8 Team. It is very easy process and you will need a active internet connection to install JDK from the internet.Finally I will show you how to set JAVA_HOME for the java 9  after the installation.

Installing Java 9 on Ubuntu

Add PPA repository to the  Ubuntu. Then update the repository information and finally install Java 9 using following commands.


sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java9-installer

Setting Java environment variables

After the installation we have to set environment variables in Ubuntu to Java 9 to use it. If there are multiple jdk versions you can use this method to select java 9 among those java version. You can automatically set Java 9 environment in Ubuntu by executing following command.


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

Check Java Version

If you have followed the tutorial successfully now java 9 should be deployed in your Ubuntu or Linux environment. You can check it using following command.


java -version

If java 9 is active on Ubuntu you should get output similar to following.


java version "1.9.0-ea"
Java(TM) SE Runtime Environment (build 1.9.0-ea-b50)
Java HotSpot(TM) 64-Bit Server VM (build 1.9.0-ea-b50, mixed mode)

Setting JAVA_HOME variable for java 9

Some java programs require you to set JAVA_HOME variable in Ubuntu before executing those application. Here how you do that. Open a new terminal without admin rights in Ubuntu (CRTL+ALT+t). Then type following command to open bashrc file in gedit editor. You can use any text editor you like.


gedit ~/.bashrc

Then append following commands to bashrc file. Make sure to remove similar commands for other java versions if you set them earlier before inserting this commands.


JAVA_HOME=/usr/lib/jvm/java-9-oracle/
export JAVA_HOME
PATH=$PATH:$JAVA_HOME
export PATH

/usr/lib/jvm/java-9-oracle/ path should be the path to the java installation directory. After that save the changes and close the terminal. Then open a new terminal.

Now is you type echo $JAVA_HOME command you can find /usr/lib/jvm/java-9-oracle/ as the output which shows that JAVA_HOME correctly set in Ubuntu.

Removing Oracle Java 9

It is very easy to remove java 9 installation from Ubuntu. Just use following command.


sudo apt-get remove oracle-java9-installer

Leave a comment