How to install Oracle Java 16 JDK on Debian

This tutorial shows how to install Oracle Java 16 JDK on Debian-based Linux distributions easily.

Below you also can find instructions to install OpenJDK from repositories and to set the JAVA_HOME path both for Oracle Java JDK and for OpenJDK…

Installing Oracle Java 16 JDK in Linux (dpkg)

To begin, visit the following link and scroll down the page to find all available downloads, as shown in the screenshot below. If you are a Debian (or based Linux distribution) user, find the .deb package pointed by the arrow. As you can see, there are also available rpm packages and sources for other Linux distributions. For instructions to install JDK on Red Hat-based distros, jump to the Installing JDK on Red Hat section.

Click the proper package to download. A confirmation window, shown in the screenshot below, will show up. Check the confirmation square and press the green button “Download jdk-X-linux-x64_bin.deb” (Where X is the current version).

Once on your computer, installing JDK in Debian is like installing any other .deb package. Run the command below to install JDK (replace the version number with the current one you just downloaded).

sudo dpkg -i jdk-16.0.2_linux-x64_bin.deb

Now JDK is installed on your device.

Removing Oracle Java 16 JDK on Debian

If you installed the .deb JDK package and want to remove Oracle Java 16 JDK in Debian-based Linux distributions, you need to use the dpkg command followed by the -r option, as shown in the example below.

Note: Replace 16.0.2 with the current version.

sudo dpkg -r jdk-16.0.2

Installing OpenJDK in Debian

You can also install OpenJDK. A free and open-source JDK version is available at Debian repositories. To install using apt, run the command below.

sudo apt install openjdk-11-jre -y

sudo apt-get install default-jdk

Installing JDK on Red Hat

 To install JDK on Red Hat-based Linux distributions, download the RPM package from the previous link.

Once downloaded, run the following command.

sudo rpm -ivh jdk-16.0.1_linux-x64_bin.rpm

For additional instructions to install JDK on other Linux distributions, visit the following links:

Set JAVA_HOME path (Oracle Java 16 JDK)

To make Java accessible to other applications, you need to define the Java_home. If using Oracle JDK, run the commands below.

export JAVA_HOME=jdk-16.0.2
export PATH=$JAVA_HOME/bin:$PATH

Set the JAVA_HOME path (OpenJDK)

 The OpenJDK JAVA_HOME is usually located at /usr/lib/jvm/java-X-openjdk-amd64 (where X is the Java version).

Run the commands below to set the JAVA_HOME path and add executables.

export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64
export PATH=$PATH:$JAVA_HOME/bin

About Java and JDK

Java is a simple, object-oriented high-level programming language. It features multi-thread, neutral architecture, high performance, and security, among other characteristics.

The JAVA Development Kit to program Java applications is what you need to create your own applications; you can find a tutorial to start programming Java at

JDK vs. OpenJDK

The main difference between OpenJDK and JDK is the same difference between most free open-source programs and their closed-coded counterparts.

JDK is a paid license and is not open-source; users can’t modify it. OpenJDK is open source and well supported by the community; users can modify it and contribute to its development.

JDK is still free for testing purposes, but costs and the improvement of the free alternative are increasing OpenJDK public.

OpenJDK is licensed under GPL, which guarantees users the right to execute, study, modify, and share. Both codes are pretty similar.

Installing Debian packages (dpkg)

The dpkg command with the -i (–install) option used in this tutorial is common to install .deb packages in Debian or similar distributions like Ubuntu. The removal instructions section shows that you can remove installed packages using dpkg with the -r flag followed by the package name.
Dpkg is Debian and based distribution packages manager. It has additional functions to package installation and removal, like printing information on installed programs. For example, to show if JDK is installed on the system and details, you can use dpkg with the -s flag. You can implement a wildcard if you don’t know the JDK version, as shown below.

dpkg -s jdk*

If the software you are checking for is installed, dpkg will return a full list of details, including the program status, priority for the system and user, description, version, and more.

Note: dpkg -s output is fully explained at How do I check if a package is installed on Debian and Ubuntu.

Installing Debian (apt)

The apt command used to install OpenJDK is a frontend for dpkg. Its main advantage is apt fetches the software from repositories and resolves dependencies automatically.
Removing packages using apt can be done with the remove option or the purge option if you want to remove configuration files.


As you can see, installing both OpenJDK and Oracle Java 16 JDK on Debian and its based Linux distributions is a few steps easy, just as installing any other .deb package. The simplicity is the same for Red Hat Linux-based distributions. Users only need to know dpkg or rpm basics.

I hope this tutorial explaining how to install Oracle Java 16 JDK on Debian and its Linux distributions was useful. Keep following Linux Hint for additional Linux tutorials and tips.

About the author

David Adams

David Adams is a System Admin and writer that is focused on open source technologies, security software, and computer systems.