Categories: LinuxShellUbuntu

Verify JAVA Installation on Ubuntu and Check the Installed version (if any)

Certain applications in Ubuntu require that Java Runtime Library is installed on your system. It does not come by default with most Ubuntu versions, as security is a concern when Java is installed on your system. Time and again, a regular Ubuntu user might need to verify if Java is installed on the system at the moment and also if it is installed, which version the system is currently using.

This article describes how you can quickly check your installed Java version on your Ubuntu system. We have tested the commands and procedures mentioned in this article on Ubuntu versions between 18.04 and 22.04.

We will use the Ubuntu command line, the Terminal, to run all the mentioned commands. You can open the Terminal application through Ubuntu Dash or the Ctrl+Alt+T shortcut.

Method 1: Checking the Java version

Once you have opened the Terminal, enter one of the following Java commands to check its version:

$ java -version

Or

$ java --version

This will ensure whether Java Runtime Environment is already installed on your system. If yes, it will also let you know which version of Java you have on your system.

In my case, the output shows that I do not have Java currently installed on my system yet.

If you have any version of Java installed on your system, the output will display Java OpenJDK and JRE version information as follows:

Method 2: By checking the path where Java is installed

Enter the following command to check the directory in which Java is installed:

$ which java

This command will print no output if Java is not installed on your system:

However, if Java is installed on your system, this command will show the exact path where Java is installed:

Method3: Search for Java in the Installed Packages list

You can check if a software package is installed on your system by using the following command syntax:

$ sudo aptitude search PackageName

We can use this command to see if any JDK package is installed on our system or not:

$ sudo aptitude search jdk

This command will list all the JDK packages available in the Ubuntu repositories.

Please note the prefix with each entry.

Only the packages with the ‘i’ prefix are installed on your system.

In the above output, you can see that Java OpenJDK 11 JRE is installed on my system. Java is not installed on your system if you do not see the ‘i’ prefix with any of the JDK entries. A more in-depth guide on finding installed packages can be found here.

Through these simple ways, you can verify whether Java is installed on your system. You can also view which Java installation you have on your system if it is indeed installed.

Karim Buzdar

About the Author: Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications. As an IT engineer and technical author, he writes for various web sites. You can reach Karim on LinkedIn

Recent Posts

How to Install Magento 2 on AlmaLinux

Magento is a free and open-source e-commerce platform written in PHP. It is simple, easy…

1 year ago

How to Install ISPConfig Hosting Control Panel with Apache Web Server on Ubuntu 24.04

ISPConfig is an open-source control panel that allows users to manage multiple servers from a…

1 year ago

How to Test your Email Server (SMTP) Using the Telnet Command

As a Linux administrator, you may find it necessary to troubleshoot or test your Simple…

1 year ago

Managing Network Interfaces and Settings on Ubuntu 24.04 with nmcli

Ubuntu 24.04, like many modern Linux distributions, relies on the NetworkManager for managing network connections.…

2 years ago

Using Restic Backup on Ubuntu 24.04

Restic is a modern, open-source backup program designed for efficiency, security, and simplicity. It enables…

2 years ago

Installing phpMyAdmin on Rocky Linux 9 and Securing it with Let’s Encrypt SSL

phpMyAdmin is a popular free tool written in PHP intended to administer MySQL and MariaDB…

2 years ago