Those who want to install the latest Oracle Java 16 (recently released) on Ubuntu, Debian and Linux distributions based on Linux distributions, such as Linux Mint, Pop! _OS, etc., can now be installed using Linux Uprising PPA. Oracle JDK 16 will receive at least two quarterly updates, and then Oracle JDK 17 will be released in September 2021.
Check out the new features of Oracle Java 16 by visiting: annouce.
I want to point out that I do not recommend Oracle Java, but I provide it to those who need it. Oracle Java uses a commercial license starting from Java 11. The license only allows free download and use of it for development and testing, but you need to pay to use it in production.You can use the open source JDK to build instead of Oracle Java, for example Use OpenJDK Or Zulu OpenJDK.
The Oracle Java 16 installer is based on the Web Upd8 Java package (the credit goes to its original creator) with minor modifications and does not contain any Oracle Java binaries. Instead, it will automatically download, install (make some adjustments, such as better font rendering, add application menu items, etc.), and selectively set Oracle Java 16 as the default Java (run update alternatives, export the JAVA_HOME environment variable) Wait). On your system.
Oracle does provide DEB packages for Oracle Java, but these packages just copy the Java binaries to
/usr/lib/jvm, Without performing any other operations, so it is exactly the same as copying the Java directory to that location yourself.
PPA provides Oracle JDK 16 for x64 and aarch64 architectures, which are the only two architectures that Oracle provides the latest Java 16.
You may also be interested in the following: How to use SDKMAN to install/switch between multiple Java versions
Use the following command to add the Oracle Java 16 PPA repository and install it on Ubuntu, Linux Mint, Pop! Update the software source on _OS or Zorin Os:
sudo add-apt-repository ppa:linuxuprising/javasudo apt update
Add the Oracle Java 16 PPA repository (and its keys) and update the software sources on Debian and other Debian-based Linux distributions (not Ubuntu-based and Ubuntu-based distributions) using the following command:
echo "deb https://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
Now, you can install Oracle JDK 16 on Debian/Ubuntu and Linux distributions based on the following:
- Install Oracle JDK 16 and set it as the default JDK version:
sudo apt install oracle-java16-installer --install-recommends
- Install but do not set Oracle JDK 16 as the default JDK version:
sudo apt install oracle-java16-installer --no-install-recommends
You can use the following commands to control whether Oracle JDK 16 is the default JDK version or comments.
oracle-java16-set-default package. If it is installed, set Oracle JDK 16 as the default. Remove this package, so Oracle Java 16 will not be set as the default (unless it is the only Java version on the system).
This package is set as the recommended package for the Oracle Java 16 installer, which is why it is installed
--install-recommends Also install
To check which version of Java on the system is set as the default version, you can run
java -version and / or
javac -version. The sample output shows that Oracle Java 16 is set as the default:
$ java -versionjava version "16" 2021-03-16Java(TM) SE Runtime Environment (build 16+36-2231)
Java HotSpot(TM) 64-Bit Server VM (build 16+36-2231, mixed mode, sharing)$ javac -versionjavac 16
In some cases, the installer may not be able to download the Oracle Java 16 .tar.gz archive file from Oracle. There may be multiple problems: you are behind a router/firewall, this is blocked, the Internet connection is lost during the download, etc.
To solve this problem, you can Download this file yourself Obtained from Oracle through other means, such as going to a friend’s house, using a web browser with a proxy, etc., and then putting the downloaded Oracle Java 16 .tar.gz file into it
/var/cache/oracle-jdk16-installer (If the folder does not exist, please create it as the root user), then install
oracle-java16-installer As mentioned above, obtain the software package from the Linux Uprising PPA.
This way, the Oracle Java 16 installer will use the local archive file instead of trying to download it yourself. Make sure that the Oracle Java 16 .tar.gz and Oracle Java Installer packages downloaded from PPA are the same version, otherwise it will not work properly.
You may also be interested: the new Oracle Java 11 installer for Ubuntu, Debian or Linux Mint (using local Oracle Java .tar.gz)
How to automatically accept Oracle Java 16 license
Downloading and installing Oracle Java 16 requires users to accept the license. In some cases, such as when using it in an automated script, you may want to use a command to automatically accept the license. You can do this using the following methods:
echo oracle-java15-installer shared/accepted-oracle-license-v1-2 select true | sudo /usr/bin/debconf-set-selections
If that doesn’t work, try the following command:
echo oracle-java15-installer shared/accepted-oracle-licence-v1-2 boolean true | sudo /usr/bin/debconf-set-selections