Java Ubuntu

Install Java on Ubuntu 24.04

Now that you have Ubuntu 24.04 installed, the remaining task is ensuring that you install all the software you need, including Java. Installing Java on Ubuntu 24.04 makes it possible to develop and run Java applications, and as a Java programmer, you will inevitably install Java on Ubuntu.Java isn’t pre-installed on Ubuntu. As such, you must know what steps are required to quickly install Java before you start using it for your projects. Reading this post will arm you with a simple procedure to install Java on Ubuntu 24.04.

Java JDK vs JRE

When installing Java on Ubuntu 24.04, a common concern is understanding the difference between JDK and JRE and knowing which to install. Here’s the thing: Java Development Kit (JDK) comprises all the required tools to develop Java applications. It comprises of the Java compiler and debugger and for someone looking to create Java apps, you must have JDK installed.

As for Java Runtime Environment(JRE), it is required for anyone looking to run Java applications on their system. So, if you only want to run Java applications without building them, you only need to install JRE and not the JDK.

As a programmer, you will likely develop and run Java applications. Therefore, you must install JDK and JRE for everything to work correctly.

How to Install Java on Ubuntu 24.04

Installing Java only requires access to an internet connection. Again, when you install the JDK, it should install the default JRE by default. However, that’s not always the case. Besides, if you want a specific version, you can specify it when running the install command.
Here, we’ve provided the steps to follow to install Java quickly. Take a look!

Step 1: Update Ubuntu’s Repository
Updating the system repository ensures that the package you install is the latest stable version. The update command refreshes the sources list, and when you install Java, you will have the updated source index for the latest version.

$ sudo update

Step 2: Install Default JRE
Before we can start installing Java, first verify that it isn’t already installed on your Ubuntu 24.04 by checking its version with the following command.

$ java --version

If Java is installed, you will get its version displayed on the output. Otherwise, you will get an output showing ’Java’ not found.

Otherwise, install the default JRE using the below command.

$ sudo apt install default-jre

The installation time will depend on your network’s speed.

Step 3: Install OpenJDK
After successfully installing JRE, you are ready to install OpenJDK. Here, you can choose to install the default JDK, which will install the available version. Alternatively, you can opt to install a specific JDK version depending on your project requirements.
For instance, if we want to install OpenJDK 17, we would execute our command as follows.

$ sudo apt install openjdk-21-jdk

During the installation process, you will get prompted to confirm a few things. Press ’y’ and hit the enter key to proceed with the installation. Once the installation is complete, you will have Java installed on your Ubuntu 24.04 and ready for use.

The last task is to verify that Java is installed. By checking the version, you will get an output showing which version is installed. If you want a different version, ensure you specify it in the previous commands, as your project requirements could be different.

$ java --version

For our case, the output shows that we’ve installed Java v21.0.3 .


Installing Java on Ubuntu 24.04 isn’t a complicated process. However, you must know what your project requirements are to guide which version you install. To recap, installing Java requires you to first update the repository. Next, install JRE and then specify what OpenJDK version to install. You will have managed to install Java on Ubuntu 24.04, and this post shares more details on each step.

About the author

Denis Kariuki

Denis is a Computer Scientist with a passion for Networking and Cyber Security. I love the terminal, and using Linux is a hobby. I am passionate about sharing tips and ideas about Linux and computing.