How To Install Oracle Java 16 On Debian, Ubuntu, Pop!_OS Or Linux Mint Using APT PPA Repository

Java logo

Those wanting to install the latest Oracle Java 16 (released recently) on Ubuntu, Debian, and Linux distributions based on these, like Linux Mint, Pop!_OS, etc., can now do so using the Linux Uprising PPA. Oracle JDK 16 will receive a minimum of two quarterly updates, before being followed by Oracle JDK 17 in September 2021.

See what's new in Oracle Java 16 by visiting the release announcement.

I'd like to note that I don't recommend using Oracle Java, however I'm making this available to those who need it. Oracle Java uses a commercial license starting with Java 11, which allows downloading and using it at no cost for development and testing only, but it requires paying a fee to use it in production. Instead of Oracle Java, you could use open source JDK builds, like those offered by AdoptOpenJDK Or Zulu OpenJDK.

This Oracle Java 16 installer is based on the Web Upd8 Java package (so the credits go to its original creators), with minor modifications, and it does not contain any Oracle Java binaries. Instead, it automatically downloads, installs (with some tweaks such as better font rendering, add applications menu entries, etc.) and optionally sets Oracle Java 16 as the default Java (runs update-alternatives, exports the JAVA_HOME environment variable, etc.) on your system. 

Oracle does offer DEB packages for Oracle Java, however, these packages simply copy the Java binaries to /usr/lib/jvm, without doing anything else, so it's exactly the same as copying the Java directory to that location yourself.

The PPA provides Oracle JDK 16 for x64 and aarch64 architectures, these being the only 2 architectures for which Oracle provides the latest Java 16.

You might also be interested in: How To Install / Switch Between Multiple Java Versions Using SDKMAN

How to install Oracle JDK 16 On Ubuntu, Debian, Linux Mint, Pop!_OS or Zorin Os using an APT PPA repository

Add the Oracle Java 16 PPA repository and update the software sources on Ubuntu, Linux Mint, Pop!_OS or Zorin Os using the following commands:

sudo add-apt-repository ppa:linuxuprising/java

sudo apt update

Add the Oracle Java 16 PPA repository (and its key) and update the software sources on Debian and other Linux distributions based on Debian (but not Ubuntu and Ubuntu-based) using:

su -

echo "deb focal main" | tee /etc/apt/sources.list.d/linuxuprising-java.list

apt-key adv --keyserver hkp:// --recv-keys 73C3DB2A

apt-get update


Now you can install Oracle JDK 16 on Debian / Ubuntu and Linux distributions based on these:

  • Install and make Oracle JDK 16 the default JDK version:
sudo apt install oracle-java16-installer --install-recommends

  • Install but don't make Oracle JDK 16 the default JDK version:
sudo apt install oracle-java16-installer --no-install-recommends

You can control if Oracle JDK 16 is the default JDK version or note with the help of the oracle-java16-set-default package. If this is installed, Oracle JDK 16 is set as default; remove this package, so Oracle Java 16 is not set as default (unless it's the only Java version on the system).

This package is set as a recommended package for the Oracle Java 16 installer, that's why installing oracle-java16-installer with --install-recommends also installs oracle-java16-set-default.

To check which Java version is set as default on your system, you could run java -version and / or javac -version. Example with output that shows Oracle Java 16 set as default:

$ java -version
java version "16" 2021-03-16
Java(TM) SE Runtime Environment (build 16+36-2231)

Java HotSpot(TM) 64-Bit Server VM (build 16+36-2231, mixed mode, sharing)

$ javac -version
javac 16

In some cases the installer may fail to download the Oracle Java 16 .tar.gz archive from Oracle. There are multiple possible issues for this: you're behind a router / firewall that prevents this, your Internet connection went down during the download process, etc. 

To work around this, you can download this file yourself from Oracle by other means, e.g. by going to a friend's house, using a web browser with a proxy, etc., and then placing the downloaded Oracle Java 16 .tar.gz file in /var/cache/oracle-jdk16-installer (create this folder as root if it doesn't exist), then install the oracle-java16-installer package from the Linux Uprising PPA as explained above.

This way, the Oracle Java 16 installer uses the local archive instead of trying to download it itself. Make sure the downloaded Oracle Java 16 .tar.gz and the Oracle Java Installer package from the PPA are both the same version, or else this won't work.

You might also be interested in: New Oracle Java 11 Installer For Ubuntu, Debian Or Linux Mint (Using Local Oracle Java .tar.gz)

How to accept the Oracle Java 16 license automatically

Downloading and installing Oracle Java 16 requires the user to accept a license. In some cases, like when using this in an automated script, you may want to automatically accept the license using a command. You can do that by using:

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

If that doesn't work, also try this command:

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