OpenJDK 11 is the open-source edition of the Oracle standard Java Platform that is available to install on almost all Linux systems using their default system repository. It is released under the GNU license and is extremely important if you are planning to install some application that requires JAVA or want to start developing applications in the JAVA programming language. Apart from the open source license the LTS ( long-term support) versions of OpenJDK offer stability and longevity, thus making it a preferable choice for enterprise implementation where the long-term reception of security patches and updates is essential. Although there is already a newer version of OpenJDK available however if you need to pick up and install version 11 on Debian 12 Linux, then this tutorial can help you out.
There are no special requirements for installing OpenJDK 11 on Debian 12, you just need access to the terminal, a user with sudo rights, and ofcourse an active internet connection for the downloading and updating of packages.
Carry out the system Update
Installing packages using locally available Debian binary would not create any issue but when we want to use the APT package manager to fetch packages from the remote repositories then it is recommended to start first with the system update. It not only rebuilds the APT package index cache but also installs the latest available system updates. Hence, run the given command:
sudo apt update
Those who also want to install the upgrades for existing packages, if available, can run the given command as well.
sudo apt upgrade
Adding SID repository with preference
Well, OpenJDK 11 is not available through the default system repositories of Debian 12 instead version 17 is there. However, we can install OpenJDK 11 by adding the SID repository of Debian meant to install the latest packages for testing. Well, also to stop this repo from installing the latest untested packages automatically we will create a preference file.
First, edit the “sources.list” file and add the following line at the end of the file:
sudo nano /etc/apt/sources.list
At the end of the file add this line:
deb http://deb.debian.org/debian unstable main non-free contrib
Save the file by pressing Ctrl+O, hit the Enter key and Ctrl+X to exit
Set preferences for the packages:
sudo nano /etc/apt/preferences
Add the following lines, this will make our Debian 12 system only choose the stable packages while updating instead of unstable ones.
Pin: release a=stable
Pin: release a=unstable
Again save the file like we did earlier using Ctrl+O.
Run system update to refresh the APT repository cache:
sudo apt update
Installing OpenJDK 11 Debian 12
Well, the OpenJDK 11 packages are available to install through the default repositories of almost all Linux distros. However, as we know in Debian 12 it is not available but after adding the SID repository we can get it like any other common package using the APT package manager. Here is the command to follow:
sudo apt install openjdk-11-jdk
Nevertheless, if you want to check out what other versions are available to install on your Debian 12 can use the given command.
sudo apt search openjdk
Verifying the Installation
If you have completed the installation command to get OpenJDK 11 on Debian 12 then you would already have it, however, still, to confirm the same we can check the JAVA version using the given command.
Set OpenJDK 11 as the default JAVA version
Now, we have the OpenJDK 11, but what if you already have OpenJDK 17 or any other version on your Debian 12 system, how will you make any one of them the system-wide default version?
Well, for that, we can use the Update-alternatives command to manage multiple versions of Java, if you have one.
sudo update-alternatives --config java
You will see the list of all Java versions installed on your Debian 12 system, now to set the one as the default enter the Selection number of that and hit the Enter key.
For example, we have JAVA 17 as the default version but we want that to be JAVA 11, so to do that will simply enter the selection number – 1 and press the Enter key.
Similarly, in the future, if we want to revert to Java 17 we run the Update-alternatives command again to select it.
OpenJDK 11 Uninstallation (optional)
In the future, if you have completed your project and don’t need Java 11 anymore on your Debian 12 system then can remove it completely using the given command:
sudo apt remove openjdk-11*
Installing OpenJDK 11 on Debian can significantly enhance your Java development environment. By following the detailed instructions in this guide, you will have the open source Java 11 without facing any major problems, yet if you have then let us know about the same using the comment section.
Frequently Asked Questions (FAQs)
- How to switch between different Java versions installed on my Debian system? Switching between different Java versions is quite easy and can be achieved by using
sudo update-alternatives --config javacommand. It will display a list of installed Java versions, we just need to enter the selection number of the corresponding version that we want to set default.
- Is OpenJDK 11 suitable for use in enterprise-level applications and development? Yes, OpenJDK 11 is well-suited for enterprise-level applications. Its Long-Term Support (LTS) status ensures stability and ongoing updates, making it a reliable choice for businesses.
- Can I install OpenJDK 11 alongside other Java versions?
Yes, we can install OpenJDK 11 alongside other Java versions. Debian to any other Linux will allow multiple Java installations and the good thing is we can switch between them using the
- What is the key difference between OpenJDK 11 and Oracle JDK?
The primary difference is in licensing and support. OpenJDK 11 is open-source and free to use, while Oracle JDK may require a commercial license for certain uses. Both offer similar performance and features, but OpenJDK is generally preferred for open-source projects.