OpenJDK is used to compile the Java source code and test the Java programs. OpenJRE is used to run the compiled Java programs. So, if you’re a Java Developer or you want to learn Java on Debian 12, you might want to install OpenJDK on Debian 12. If you just want to run the Java programs on Debian 12, installing just OpenJRE is enough.
In this article, we will show you how to install Java OpenJDK and OpenJRE on the Debian 12 desktop. We will also show you how to install Java OpenJDK and OpenJRE on the Debian 12 headless server.
NOTE: If you’re looking to install the Oracle Java Development Kit (JDK) on Debian 12, read the article on How to Install Oracle Java Development Kit (JDK) on Debian 12.
Topic of Contents:
- Updating the Debian 12 Package Database Cache
- Installing Java OpenJDK on Debian 12
- Checking Whether OpenJDK Is Installed Correctly on Debian 12
- Installing the Java OpenJRE on Debian 12
- Checking Whether OpenJRE Is Installed Correctly on Debian 12
- Conclusion
Updating the Debian 12 Package Database Cache
First, update the APT package database cache of Debian 12 with the following command:
Installing Java OpenJDK on Debian 12
If you’re a Java developer or you want to learn to Java program – you want to write the Java programs, compile them, and test them on Debian 12 – you need to install OpenJDK on Debian 12.
On Debian 12, you can install either the full version of OpenJDK or the headless version of OpenJDK. The full version of OpenJDK comes with Java GUI programming libraries and can run the graphical Java apps as well. The headless version of OpenJDK works with only the command-line Java apps. If you’re using a Debian 12 desktop environment, install the full version of OpenJDK. If you’re using a Debian 12 headless server, install the headless version of OpenJDK.
To install the full version of OpenJDK on Debian 12 desktop, run the following command:
To install the headless version of OpenJDK on Debian 12 server, run the following command:
To confirm the installation, press Y and then press <Enter>.
OpenJDK and all the required dependency packages are being downloaded from the internet. It takes a few seconds to complete.
OpenJDK and all the required dependency packages are being installed. It takes a few seconds to complete.
At this point, OpenJDK should be installed on Debian 12.
Checking Whether OpenJDK Is Installed Correctly on Debian 12
Once OpenJDK is installed, run the following commands to check whether you can access OpenJDK:
$ java --version
As you can see, the OpenJDK compiler version 17 and OpenJDK runtime environment version 17 are installed on our Debian 12 machine.
Installing Java OpenJRE on Debian 12
If you just want to run the Java programs on Debian 12, you need to have OpenJRE installed on your Debian 12 machine.
If you want to run the Java GUI programs on your Debian 12 desktop, you have to install the full version of OpenJRE. If you want to run only the Java command-line programs on your Debian 12 headless server, you can install the headless version of the OpenJRE.
To install the full version of OpenJRE on your Debian 12 desktop, run the following command:
To install the headless version of OpenJRE on your Debian 12 headless server, run the following command:
To confirm the installation, press Y and then press <Enter>.
OpenJRE and all the required dependency packages are being downloaded from the internet. It takes a few seconds to complete.
OpenJRE and all the required dependency packages are being installed. It takes a few seconds to complete.
At this point, OpenJRE should be installed on Debian 12.
Checking Whether OpenJRE Is Installed Correctly on Debian 12
Once OpenJRE is installed, run the following command to check whether you can access OpenJRE:
As you can see, the Java runtime environment version 17 is installed on our Debian 12 machine.
Conclusion
We showed you how to install Java OpenJDK and OpenJRE on the Debian 12 desktop. We also showed you how to install Java OpenJDK and OpenJRE on the Debian 12 headless server.