Verify Java Installation on Debian and Check the Installed version (if any)

Java is one of the most common programming languages that is used for developing and running a wide range of applications. By default, Linux distributions including Debian does not ship with the java (Java Runtime Environment, JRE) installed. However, sometimes in order to run certain programs, we may need to know if the java is running in our system or not and also what version it is currently running.

In this article, we will learn different ways using which you can verify if Java is installed in your system along with its version. We have used Debian 10 for running the commands and procedures mentioned in this article.

We will need the Terminal application in order to run the procedure. To launch Terminal in your Debian OS. go to the Activities tab in the top left corner of your desktop. Then from the search menu that appears, search for the Terminal application and launch it.

Get the Java version

Enter the following in the Terminal to check which version of java is installed.

$ java -version

Or

$ java --version

It will verify the java runtime environment has installed on your system along with the version of java you are running on your system.

If you receive the output similar to what is shown in the following image, then Java is not installed in your system.

Check java Version on Debian

If you have Java installed on your system, you will see the Java OpenJDK and JRE version details as follows:

Java Version information

Check if Java is installed

Another way to verify java installation is to check the path where Java is installed. To do so, run the following command in Terminal:

$ which java

You will receive the following output if java is installed on your system otherwise you will receive no output.

Check Java path

Search for Java in the Installed Packages list

You can also verify any software installation in your system by searching it from the list of installed packages. The following syntax can be used for this purpose:

$ sudo aptitude search PackageName

To verify if any Java package is installed in your system or not, run the following command in Terminal.

$ sudo aptitude search jdk

The above command will display all JDK packages available in Debian repositories. The first letter of each line represents the package’s current state, a line starting with “i” prefix is the one which is installed on your system.

From our below output, you can see that Java openjdk-11-jdk is installed in our system. If you don’t find the prefix “i”, that will indicate the java is not installed in your system.

Check which java / JDK package is installed

Using the dpkg utility to find which java package is installed

Dpkg is the command-line utility that is used to obtain the list of installed packages on the Linux OS. We can use it to find the version of java installed in your system. to do so, run the following command in Terminal:

$ dpkg --list | grep -i jdk

List packags with dpkg

Using the above-described methods, you can verify if Java is installed on your system or not. Along with this, you can verify the version of java installed.