How to install Java on Linux Mint

Endrit Qerreti

Endrit Qerreti

Java is a programming language that is used in many applications as the main programming language. To be able to run applicatons that are built with Java, you must have Java installed on your system.

Having Java installed on Linux Mint, not only allows you to run Java based apps, but it also allows you to create and develop Java projects on your machine.

Installing Java on Linux Mint, is quite simple, as java is available in the default Linux Mint repositories, which means you can install Java directly from terminal, without having to download or build Java manually.

In this tutorial, you will learn how to install Java Runtime Environment (JRE) and Java Development Kit (JDK) on Linux Mint.

Step 1 - Update the system

Before installing Java runtime environment, and Java Development Kit on Linux Mint, you must check for updates, and upgrade packages that needs to be upgraded, so that you don't face issues during the installation process.

To check for updates and upgrade packages automatically, simply run the commands below.

sudo apt update && apt upgrade -y

Step 2 - Install Java Runtime Environment on Linux Mint

Java is pre installed on many Linux Distros, including Linux Mint. To check which version of Java runtime Environment is installed on your Linux Mint system, simply run the command below.

java --version

As you can see, Java runtime environment 11 is currently installed on our Linux Mint system.

However, if you don't see an output when checking which Java version is installed on your system, then it means that Java is not installed.

To install Java runtime environment on Linux Mint is quite simple, and it can be done directly from the terminal, by downloading the default-jre package.

default-jre package will install the recommended Java runtime environment for Linux Mint, which is Java Runtime Environment 11.

sudo apt install default-jre

Alternatively, you can also install Java runtime environment 11 directly from the terminal, without having to install default-jre package.

To do so, simply run the command below.

sudo apt install openjdk-11-jre

Step 3 - Install Java Development Kit (JDK) on Linux Mint

Now that Java runtime environment is installed on your system, you can proceed to install Java Development kit.

Installing Java Development Kit on Linux Mint, is very simple, and it can be done via apt package manager, as Java Development Kit package is available in the default Linux Mint repositories.

To install Java Development Kit, simply execute the command below.

sudo apt install openjdk-17-jdk

💡
Note: OpenJDK 17 is a LTS release, and it will be supported until October 2027. The most recent version of OpenJDK, is OpenJDK version 21 which is also a LTS release, and it will be supported until December 2029.

To install OpenJDK 21 on Linux Mint, simply run the command below.

sudo apt install openjdk-21-jdk

Step 3 - Verify Java Installation on Linux Mint

Now that Java runtime environment (JRE) and Java Development Kit (JDK) are installed on your Linux Mint system, you need to verify that both packages were installed correctly.

To do so, simply check Java version, by executing the command below.

java -version

The command above, will display which version of Java Runtime Environment and Java Development Kit your system is running.

As you can see in the screenshot below, we are now running Java Runtime Environment(JRE) 11 and Java Development Kit(JDK) 17 on our Linux Mint machine.

Conclusion

In this tutorial, you learned how to install JRE and JDK on Linux Mint, directly from the terminal by using apt package manager.

By now you should be able to run Java based apps on your system, and also be able to use JDK to run Java code and develop Java applications on Linux Mint.