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


Oracle released Java 12 last week, and the new release can now be installed in Ubuntu, Linux Mint and Debian from the Linux Uprising Java PPA. The new version will receive a minimum of 2 updates, and it will followed by Oracle JDK 13 in September 2019.

The release announcement contains information about Oracle Java 12, including what's new.

Like previously mentioned, Oracle uses a new commercial license for Java starting with Java 11, so you should use OpenJDK when possible. From Java 11 forward, Oracle JDK builds and OpenJDK builds are essentially identical with a few differences you can read about here.

This Oracle Java 12 installer for Ubuntu, Debian and Linux Mint is based on the Web Upd8 Java package with some minor modifications, and it only works on 64bit, since Oracle only offers a 64bit Java 12 binary for Linux. The installer downloads Oracle Java 12, runs update-alternatives for the Java binaries and man pages, and it can optionally set Oracle JDK 12 as the default Java (set JAVA_HOME environment variable, etc.).


How to install Oracle Java 12 in Ubuntu, Debian or Linux Mint using apt repository

To add the Linux Uprising Java PPA and install Oracle Java 12 in Ubuntu or Linux Mint (64bit), use:

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

For Debian 64bit, add the repository manually and then install Oracle Java 12:

su -

echo "deb http://ppa.launchpad.net/linuxuprising/java/ubuntu bionic main" | tee /etc/apt/sources.list.d/linuxuprising-java.list

apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 73C3DB2A

apt-get update

apt-get install oracle-java12-installer


To make Oracle Java 12 default, install the oracle-java12-set-default package (this is the same for Ubuntu, Linux Mint, Debian, etc.):

sudo apt install oracle-java12-set-default

This package is recommended by the oracle-java12-installer package, so it may be installed by default (it's installed by default on Ubuntu but not on Linux Mint). In case oracle-java12-set-default is installed, and you don't want Oracle Java 12 as the default Java, all you have to do is remove this package:

sudo apt remove oracle-java12-set-default

The default Java version can be checked by using java -version and javac -version, for example:

$ java -version
java version "12" 2019-03-19
Java(TM) SE Runtime Environment (build 12+33)
Java HotSpot(TM) 64-Bit Server VM (build 12+33, mixed mode, sharing)

$ javac -version
javac 12

Alternate download option

Want to install Oracle Java 12 and you're behind some router or firewall that doesn't allow downloading the JDK .tar.gz archive from Oracle's servers?

You can download the Oracle Java 12 Linux .tar.gz using your web browser or a different computer, then on the computer where you want to install Oracle Java 12, create a /var/cache/oracle-jdk12-installer folder and place the Linux JDK 12 .tar.gz in this folder.

After this, install the oracle-java12-installer package using the instructions from this article, and the installer will pick up your local copy of the .tar.gz archive, and won't try to download it from Oracle.

How to auto-accept the Oracle Java 12 license

Want to automatically accept the Oracle Java 12 license? This may be useful for automation - running the Oracle JDK 12 installer in a script, etc. You can accept the license by using this command:

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

If that doesn't work, you may also want to try this to auto-accept the Oracle Java 12 license:

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