Many developers and programmers choose to use a Linux system as their work environment because of its stability, speed, and ease of use. To get started with programming Java, or to simply run Java applications or applets on Linux, you will need to install the appropriate Java software package. Although this is pretty easy to do, the instructions will vary depending on a user’s Linux distribution, what version of Java they wish to use, and whether they need the JDK (Java Development Kit) or just the JRE (Java Runtime Environment).
In this tutorial, we will go over the step by step instructions to install Java on all major Linux distros. This will include all the relevant versions of Java that are available for installation in official repositories, and the JDK and JRE packages. If this sounds confusing, do not worry, we will go over the differences and help you select the right package to install for your needs.
In this tutorial you will learn:
- How to install Java JDK and JRE on major Linux distros
- What is the difference between JDK and JRE
- How to search for a Java version to install

Category | Requirements, Conventions or Software Version Used |
---|---|
System | Any Linux distro |
Software | Java (JDK and JRE) |
Other | Privileged access to your Linux system as root or via the sudo command. |
Conventions |
# – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command$ – requires given linux commands to be executed as a regular non-privileged user |
Java JDK vs JRE
You have the option to install either the JDK or JRE package:
The Java Development Kit includes the necessary tools to develop Java applets and applications. If you plan to do any coding in Java, then this is the package you will want. It will also include the JRE (Java Runtime Environment) files, so you will be able to run any Java programs that you create or download.
The Java Runtime Environment includes only the files that are necessary to run Java applications. If you do not plan to do any coding in Java, and just need to make your machine capable of running programs that are written in Java, then the JRE will suffice for you.
Install Java on all Major Linux Distros
You can use the appropriate command below to install the JDK or JRE software with your system’s package manager.
To install JDK or JRE on Ubuntu, Debian, and Linux Mint:
$ sudo apt install default-jdk OR $ sudo apt install default-jre
To install JDK or JRE on Fedora, CentOS, AlmaLinux, and Red Hat:
$ sudo dnf install java-latest-openjdk # all in one package
To install JDK or JRE on Arch Linux and Manjaro:
$ sudo pacman -S jdk-openjdk OR $ sudo pacman -S jre-openjdk
After installing your Java package, you can create a simple Hello World Java program and run it to verify that the installation was successful and your system is now capable of executing Java programs.
Picking a Different Java Version
For most cases, users will simply need to install the latest version of Java JDK or JRE, or at least the latest version available in the distribution’s official software repository. If you are in a situation where you need a particular version of Java to install, here is how to search your distribution’s software repo to see what versions are available:
To search for Java with the apt command in distributions like Ubuntu, Debian, Linux Mint, Kali, and MX Linux:
$ sudo apt search jdk
To search for Java with the dnf
command in distributions like Fedora, Red Hat, CentOS, Rocky Linux, and AlmaLinux:
$ sudo dnf search jdk
To search for Java with the pacman
command in distributions like Arch Linux and Manjaro:
$ sudo pacman -Ss jdk

Closing Thoughts
In this tutorial, we saw how to install Java on a Linux system. While this process is straightforward, unexpecting users often get confused since the instructions vary for every Linux distribution, and acronyms like JDK and JRE get tossed around, usually with no explanation. All the different Java versions can also serve to complicate the installation process. Now you know how to install the latest JDK or JRE for your Linux distro, as well as find other versions available if necessary.