How To Install Oracle Java 15 On Ubuntu, Debian Or Linux Mint Using APT PPA Repository

Oracle Java


Oracle has released Java 15 a couple of days ago. Those wanting to install this in Ubuntu, Debian, and Linux distributions based on these, like Pop!_OS, Linux Mint, Zorin OS, etc., can use the Linux Uprising Java PPA. Oracle JDK 15 will receive a minimum of two quarterly updates, before being followed by JDK 16 in March 2021.
To see what's new in Oracle Java 15, see the release announcement.

I'd like to note that I don't recommend using Oracle Java, however I'm making this available to those that 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 15 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 and optionally sets Oracle Java 15 as the default Java (runs update-alternatives, exports the JAVA_HOME environment variable, etc.) on your system. 

For Oracle Java 15, there are available x64 and aarch64 Linux builds. Oracle stopped providing ARM builds for quite a few releases, until this latest Oracle Java 15. 

This is the first time since I've taken over this package that Oracle releases ARM binaries, so let me know if you encounter ARM-related issues with the package. 

Install Oracle Java 15 on Ubuntu, Debian, Linux Mint, Pop!_OS, Zorin OS and others using an APT PPA repository


The package from this PPA downloads and installs Oracle Java 15 for you (with applications menu / 'open with' entries). If you choose to make this Java version default (by installing the oracle-java15-set-default package), the package updates the alternatives to set all Java binaries from this package as default, and exports the JAVA_HOME environment variable for this Java version (requires a logout/relogin to take effect). 

Oracle offers its own DEB packages for download, but they only copy the Oracle Java 15 files to your system, and nothing more. It doesn't allow setting it as the default Java, doesn't set the JAVA_HOME environment variable, it doesn't create menu entries, etc. 

Ubuntu, Linux Mint, Pop!_OS and other Linux distributions based on Ubuntu: open a terminal and use the commands below to add the Linux Uprising Oracle Java PPA and install Oracle Java 15 (Oracle JDK 15) for x64 / aarch64 only:

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

Debian and other Linux distributions based on Debian but not Ubuntu (without add-apt-repository available by default) users: open a terminal and run the following commands to add the Linux Uprising Oracle Java PPA repository, and install Oracle JDK 15: 

su -

echo "deb http://ppa.launchpad.net/linuxuprising/java/ubuntu focal 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-java15-installer

exit

This installs Oracle Java 15, and on Linux distributions that automatically install recommended packages, like Ubuntu, it also installs the oracle-java15-set-default package, which makes Oracle Java 15 the default Java version on that system. In case you want to skip the installation of oracle-java15-set-default like this: 

sudo apt install --no-install-recommends oracle-java15-installer

Or, for Linux distributions on which recommended packages are not installed by default, and you want to make this Oracle Java 15 default on your system, manually install the oracle-java15-set-default package: 

sudo apt install oracle-java15-set-default

If you don't want to have Oracle Java 15 as the default Java version on your system, remove oracle-java15-set-default using: 

sudo apt remove oracle-java15-set-default

You can check which Java version is default on your system by opening a terminal and typing java -version and / or javac -version. Example from my system: 

$ java -version
java version "15" 2020-09-15
Java(TM) SE Runtime Environment (build 15+36-1562)
Java HotSpot(TM) 64-Bit Server VM (build 15+36-1562, mixed mode, sharing)

$ javac -version
javac 15

You might also like: How To Install / Switch Between Multiple Java Versions Using SDKMAN

How to automatically accept the Oracle Java 15 license


Downloading and installing Oracle Java 15 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-java15-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-java15-installer shared/accepted-oracle-licence-v1-2 boolean true | sudo /usr/bin/debconf-set-selections

What to do in case the download fails


What if the Oracle Java 15 installer fails to download Oracle Java? This can happen in case you're behind some firewall, router or proxy that prevents the installer from downloading the Oracle Java archive. 
 
There's a workaround for such cases though. You can download the Oracle Java 15 .tar.gz file 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 15 .tar.gz file in /var/cache/oracle-jdk15-installer (create this folder as root if it doesn't exist), then install the oracle-java15-installer package from the Linux Uprising PPA as explained above. 
 
Instead of trying to download the Oracle Java 15 .tar.gz archive itself, the installer will use the local version you've downloaded manually. 

Make sure the downloaded Oracle Java 15 .tar.gz and the Oracle Java Installer package from the PPA are both the same version, or else this won't work.