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:
Confirm Java version on Debian through the following command:
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:
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:
For installing the updated Java version from the apt package manager, which is 17, you must use the following command:
Note: If you have installed multiple Java version on Debian, you can switch to any version you want using the following command:
Conclusion
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.