How To Install Oracle Java 11 In Ubuntu, Linux Mint Or Debian (From PPA Repository)

Oracle Java 11, the first long term support release, can now be installed in Ubuntu, Linux Mint and Debian from the Linux Uprising Java PPA. For what's new in the latest JDK11, read the release notes.

It's important to note that with Java 11, Oracle uses a new, commercial license. It can be downloaded and used without cost only for development and testing only, and it requires paying a fee if it's used in production:

You may not: use the Programs for any data processing or any commercial, production, or internal business purposes other than developing, testing, prototyping, and demonstrating your Application.

This quote is from the Oracle Java SE license (via).

As a result, you should only use Oracle JDK if you intend to pay for it. Use OpenJDK, which is available in the Debian / Ubuntu repositories, for anything else. From Java 11 forward, Oracle JDK builds and OpenJDK builds are essentially identical with a few differences you can read about here.

Update: the Oracle JDK license has changed starting April 16, 2019. The new license permits certain uses, such as personal use and development use, at no cost -- but other uses authorized under prior Oracle JDK licenses may no longer be available. A FAQ is available here. After this change, new Oracle Java 11 releases (11.0.3 and newer) require signing in using an Oracle account to download the binaries, so I can't update the PPA with new packages (the last version in the PPA being 11.0.2). If you want to continue using newer Oracle Java 11 versions, and you have an Oracle account so you can download newer Oracle Java builds, see this article: Install Any Oracle Java (JDK) Version In Ubuntu, Debian, Linux Mint Or Fedora With

Oracle Java 11 is available to download as a DEB package, but all the package does is install the files to /usr/lib/jvm/jdk-11, just like it would be if you copied the extracted directory there, without any options to set it as default / update the Java alternatives, set environment variables and so on.

The Oracle Java installer from the Linux Uprising PPA can set Java 11 as default, set environment variables (JAVA_HOME, etc.) and easily undo this. The installer downloads Oracle Java 11 (64bit only as that's what Oracle provides) from Oracle's servers because the license doesn't allow uploading the binary to the PPA.

The package in this PPA uses the Web Upd8 Java package installer as a base, but it's modified to install the latest Oracle JDK 11.

If you decide to use OpenJDK instead of Oracle Java: Users running Ubuntu 18.04 or older can install OpenJDK by using an official Ubuntu PPA. You might notice there's an openjdk-11-jdk package in Ubuntu 18.04 (and Linux Mint 19), but that package actually contains OpenJDK 10. The PPA I mentioned provides the actual OpenJDK 11 package. See this article for more information and installation instructions: How To Install OpenJDK 11 In Ubuntu 18.04, 16.04 or 14.04 / Linux Mint 19, 18 or 17.

Related: How To Install Oracle Java 12 (JDK 12) In Ubuntu, Linux Mint Or Debian (Using PPA)

Install Oracle Java 11 (JDK 11) in Ubuntu, Linux Mint or Debian from PPA

Oracle Java 11 Ubuntu

To add the LinuxUprising Java PPA repository to your software sources and install Oracle Java 11 in Ubuntu or Linux Mint (64bit only) you can use the commands below:

sudo add-apt-repository ppa:linuxuprising/java
sudo apt update
sudo apt install oracle-java11-installer

In Debian (64bit only) you can add the repository and install Oracle Java 11 using these commands:

su -
echo "deb bionic main" | tee /etc/apt/sources.list.d/linuxuprising-java.list
apt-key adv --keyserver hkp:// --recv-keys 73C3DB2A
apt-get update
apt-get install oracle-java11-installer

The oracle-java11-installer package has a Recommends field for the oracle-java11-set-default package, which sets Oracle Java 11 as default (including setting the JAVA_HOME environment variable, which requires a session restart). Such recommended packages are installed automatically on Ubuntu, but are not on other Debian-based Linux distributions.

So to make Oracle Java 11 default, install the oracle-java11-set-default package:

sudo apt install oracle-java11-set-default

If you want to have Oracle Java 11 installed but not set it as the default Java, make sure the oracle-java11-set-default package is not installed / remove it:

sudo apt remove oracle-java11-set-default

You can check to see if Oracle Java 11 is set as default by checking your current Java version using the following command:

java -version

If Oracle Java 11 is default, you should see an output similar to the following:

java version "11" 2018-09-25
Java(TM) SE Runtime Environment 18.9 (build 11+28)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11+28, mixed mode)

You can try it for javac as well:

javac -version

Which should return an output similar to the one below:

javac 11

This package supports installing Java 11 by manually downloading the archive. This is useful in case you're behind a firewall or your ISP somehow blocks the Oracle JDK 11 download link (so you can download it from a different computer, etc.). To do this, download the Oracle Java 11 tar.gz archive and place it in the /var/cache/oracle-jdk11-installer folder. Next, install the oracle-java11-installer package using the regular instructions and it should pick up the downloaded tar.gz archive instead of downloading it.

Automatically accept the Oracle Java 11 lincense (for automated installations)

By default, the Oracle Java 11 installer prompts you to accept the Oracle Java license before proceeding with the JDK 11 installation. If you want to automate the Oracle Java 11 installation process, use the following command to automatically accept the license:

echo oracle-java11-installer shared/accepted-oracle-license-v1-2 select true | sudo /usr/bin/debconf-set-selections

If the command above doesn't automatically accepts the Oracle Java 11 license, try the command below instead:

echo oracle-java11-installer shared/accepted-oracle-licence-v1-2 boolean true | sudo /usr/bin/debconf-set-selections