(Last Updated On: November 18, 2018)

In this tutorial, I’ll walk you through the steps to install Oracle Java 11 on Ubuntu 18.04 /16.04 / Debian 9. Java 11 is a long-term support (LTS) release made available to the General public on 25 September 2018 and is production-ready.

You can install Java 11 on Ubuntu 18.04 /16.04 / Debian 9 either from one of the following methods:

  1. Java SE Development Kit 11 (JDK 11)
  2. OpenJDK 11

It is recommended to install OpenJDK 11 because of the license issues around Java SE Development Kit. This guide will cover the installation of Oracle Java 11 on Ubuntu 18.04 /16.04 / Debian 9 from both methods.

Install OpenJDK 11 on Ubuntu 18.04 /16.04 / Debian 9

OpenJDK is a free and open-source implementation of the Java Platform, Standard Edition licensed under the GNU General Public License version 2.

Check the latest release of OpenJDK 11 before running the command below:

curl -O https://download.java.net/java/GA/jdk11/13/GPL/openjdk-11.0.1_linux-x64_bin.tar.gz

This will download OpenJDK 11 tar file to your working directory. After the download, extract the archive

tar zxvf openjdk-11.0.1_linux-x64_bin.tar.gz

Move the resulting folder to /usr/local/

sudo mv jdk-11* /usr/local/

Set environment variables

sudo vim /etc/profile.d/jdk.sh

Add:

export JAVA_HOME=/usr/local/jdk-11.0.1
export PATH=$PATH:$JAVA_HOME/bin

Source your profile file and check java command

$ source /etc/profile
$ java -version
openjdk version "11.0.1" 2018-10-16
OpenJDK Runtime Environment 18.9 (build 11.0.1+13)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.1+13, mixed mode)
$ which java
/usr/local/jdk-11.0.1/bin/java

Install Java SE Development Kit 11 (JDK 11) on Ubuntu 18.04 /16.04 / Debian 9

Download the latest release of JDK 11.

curl -LO -H "Cookie: oraclelicense=accept-securebackup-cookie" \
"http://download.oracle.com/otn-pub/java/jdk/11.0.1+13/90cf5d8f270a4347a95050320eef3fb7/jdk-11.0.1_linux-x64_bin.deb"

Then install the package with the dpkgcommand

sudo dpkg -i jdk-11.0.1_linux-x64_bin.deb

If you encounter dependency issues, then run:

$ sudo apt -f install
$ sudo dpkg -i jdk-11.0.1_linux-x64_bin.deb
Reading database ... 105838 files and directories currently installed.)
Preparing to unpack jdk-11.0.1_linux-x64_bin.deb ...
Unpacking jdk-11.0.1 (11.0.1-1) over (11.0.1-1) ...
Setting up jdk-11.0.1 (11.0.1-1) ...

Set environment variables

sudo vim /etc/profile.d/jdk.sh

Add:

export JAVA_HOME=/usr/lib/jvm/jdk-11.0.1/
export PATH=$PATH:$JAVA_HOME/bin

Source the file and confirm Java version installed

$ source /etc/profile.d/jdk.sh
$ java -version 
java version "11.0.1" 2018-10-16 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.1+13-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.1+13-LTS, mixed mode

For CentOS 7 & Fedora Linux distributions, refer to:

How to Install Java 11 on CentOS 7 / Fedora 29 / Fedora 28