How to Install Java on Debian with apt

Java is a popular programming language that allows users to run mobile applications, servers, and other high-end applications. It is important for the system users since with the help of it, they will be able to run applications that require Java. By default, Java is installed on Windows-based systems, but on Debian, you have to install it manually. Debian has a default apt package manager for installing applications so, people will probably be looking for the right command to install Java with the apt package manager.

Follow this article’s procedure to find different ways to install Java on Debian with apt.

Install Java on Debian with apt

There are different methods to install Java on Debian with apt, which are discussed below:

Method 1: Install Default Java Version on Debian

The Debian official repository includes the installation of the default Java package that allows users to install Java 11 on the system. If you are interested in installing the Java 11 version on Debian, use the following command:

sudo apt install default-jdk

Confirm Java version on Debian through the following command:

java --version

Method 2: Install Java 11 or 17 Version with apt

You can also apply different commands to install a similar Java 11 version or an updated one (Java 17) from the “apt” command. However, before that, you must have to look at the Java packages in the Debian repository and this can be done using the following command:

apt list OpenJDK\*

The above commands show you the list of Java packages that can be installed on Debian.

So, if you want to install Java 11 on Debian, use the following command:

sudo apt install openjdk-11-jdk

For installing the updated Java version from the apt package manager, which is 17, you must use the following command:

sudo apt install openjdk-17-jdk

Note: If you have installed multiple Java version on Debian, you can switch to any version you want using the following command:

sudo update-alternatives --config java


Java is a useful tool for creating servers and high-end applications. It must be installed on your system if you want to run Java-dependent applications on the system. On Debian, you can install the default Java version (Java 11) or Java 17 from the apt package manager. The commands to install these versions are already mentioned above in the guidelines.

About the author

Awais Khan

I'm an Engineer and an academic researcher by profession. My interest for Raspberry Pi, embedded systems and blogging has brought me here to share my knowledge with others.