How to Install OpenJDK 17 on Linux Mint 20

Java is a general-purpose, class-based, object-oriented multipurpose programming language that is popular due to the design of having lesser implementation dependencies, meaning that the compiled Java code can be run on all platforms that support Java without the need for recompilation. Java is also fast, secure, and reliable, therefore. It is widely used for developing Java applications in laptops, data centers, game consoles, scientific supercomputers, cell phones, etc.

The tutorial will install the OpenJDK version instead of the default Oracle JDK. The difference between these two is licensing. OpenJDK is an entirely free open-source Java with a GNU General Public License, and Oracle JDK requires a commercial license under the Oracle Binary Code License Agreement. Other differences are release schedules and other factors that come into play; however, performance is pretty much the same.

In the following tutorial, you will learn how to install the latest OpenJDK 17 LTS on Linux Mint 20.


Update Operating System

Update your Linux Mint operating system to make sure all existing packages are up to date:

sudo apt update && sudo apt upgrade -y

The tutorial will be using the sudo command and assuming you have sudo status.

To verify sudo status on your account:

sudo whoami

Example output showing sudo status:

[joshua@linuxmint ~]$ sudo whoami

To set up an existing or new sudo account, visit our tutorial on Adding a User to Sudoers on Linux Mint.

To use the root account, use the following command with the root password to log in.


The tutorial will be utilizing the terminal, and for those unfamiliar, this can be found in your show applications menu.


How to Install OpenJDK 17 on Linux Mint 20

Option 1. Install OpenJDK 17 with APT

The first and most recommended option is to install OpenJDK using the default repository. First, search to find what is available.

In your terminal, use the following command.

apt-cache search openjdk

Example output:

How to Install OpenJDK 17 on Linux Mint 20

As the above output states, OpenJDK 17 JDE and JRE are available to install.

To begin the installation, use the following terminal command.

Install OpenJDK 17 – JRE:

sudo apt-get install openjdk-17-jre

Install OpenJDK 17 – JDK:

sudo apt-get install openjdk-17-jdk

Confirm the installation by running the following command.

java --version

Example output:

How to Install OpenJDK 17 on Linux Mint 20

Updates are handled with the standard apt update and upgrade commands. However, you can remove them separately or altogether if you no longer require JDK or JRE.


sudo apt-get remove openjdk-17-jre openjdk-17-jdk --purge

Note, this will remove any unrequited leftover dependencies and thoroughly wipe the installation and data as much as possible from your system.

Alternative Method – Install OpenJDK with PPA

The default APT repository often has the latest up-to-date and secure versions. An alternative method is to add the ppa:openjdk-r/ppa repository, which is always up to date and may see updates deployed quicker than default archives.

The PPA is untrusted, which in short terms, has no affiliation with the Ubuntu or Linux Mint core team. However, it has been around for a long time and is widely used in larger communities.

Note, you do not need to remove and default OpenJDK installations. You can install this PPA directly. If any updates are available, it will simply prompt you to update your version from its repository.

First, add the PPA using the following command.

sudo add-apt-repository ppa:openjdk-r/ppa -y

Next, you can install JDK, JRE, or both together.

sudo apt-get install openjdk-17-jre openjdk-17-jdk

Users that already have the above installed just run an update to check if any newer versions are available.

sudo apt update && sudo apt upgrade

For users that no longer wish to use this PPA, you will need to remove the OpenJDK versions off your system first.

sudo apt-get autoremove openjdk-17-jre openjdk-17-jdk --purge

Then remove the PPA with the -r flag for removal.

sudo add-apt-repository -r ppa:openjdk-r/ppa -y

Then repeat the original process if you want to re-install from the default repository or use the manual method below.

Option 2. Install OpenJDK 17 Manually

The second option is to install OpenJDK 17 by downloading the .tar.gz archive package. This is often more up-to-date than the default APT repo version, but you will need to keep an eye on new updates and re-do the process, which can be a burden if you keep forgetting.

Download Latest OpenJDK 17 Build

Visit the downloads page to get the latest build version link, then use the following wget command.


Linux  AArch64 users:


Linux  x64 users (Majority of users):


Once the download is complete, you need to extract the archive.

tar -xvf openjdk-17.0.1_linux-{version number}


tar -xvf openjdk-17.0.1_linux-x64_bin.tar.gz

Remember, in future versions, and the file name will change, a quick method is to type OpenJDK-17 then press your TAB key to complete the file name.

Configure and Install OpenJDK 17

Next, move the extracted archive directory into the /opt/ location:

sudo mv jdk-17.0.1 /opt/

Now you need to set the environment variables, copy and paste the below into your terminal.

export JAVA_HOME=/opt/jdk-17.0.1
export PATH=$PATH:$JAVA_HOME/bin

Remember, change jdk-17.0.1 with the current directory name if you want it or have future updated versions.

To confirm the installation, run the following command.

java --version

If installed correctly, you should see the following output:

How to Install OpenJDK 17 on Linux Mint 20

As you can see, you can see the version is the latest OpenJDK 17 build. Remember, you must check back and re-do the process for future updates.

Test Java – Create Hello World Application

To finish off, it is always handy to test installations of these kinds to confirm everything is working correctly after being installed. The easy way is to create a small test using the famous Hello World example.

First, create the Java program file as follows

sudo nano

Next, add the following Java code into the file:

public class hello {
  public static void main(String[] args) {
    System.out.println("G'day from LinuxCapable!");

Save the file (CTRL+O), then exit (CTRL+X).

Next, compile the code using the following terminal command javac.


Finally, run the Java code with the following command:

java hello

Example output:

How to Install OpenJDK 17 on Linux Mint 20

Congratulations, everything is working correctly.

Comments and Conclusion

In the tutorial, you have learned how to download and install OpenJDK 17 latest version by learning two methods, downloading and future versions and installing with the same process for your Linux Mint desktop or headless system.


Like to get automatic updates? Follow us on one of our social media accounts!