OpenJDK 11 is a free, open-source implementation of the Java SE 11 Platform, which includes the Java Development Kit (JDK) and Java Runtime Environment (JRE). It was released on September 25, 2018, and is the long-term support (LTS) version of OpenJDK, meaning it will receive security and bug fixes longer than non-LTS releases.
Some of the new features and improvements introduced in OpenJDK 11 include the following:
- Flight Recorder: a low-overhead event recording framework for troubleshooting, profiling, and auditing Java applications
- HTTP Client API: a standard HTTP client API introduced as an incubator module in Java SE 9 and made available in the java.net.http module in Java SE 11
- Epsilon GC: a no-op garbage collector that provides a low-overhead way to handle small heaps or test certain scenarios without GC interference
- ZGC: a scalable low-latency garbage collector that can handle heaps ranging from a few hundred megabytes to multiple terabytes in size
- Improved security: new and enhanced cryptographic algorithms and security features, such as ChaCha20-Poly1305 and TLS 1.3, support
As a developer or user, you may still need to install OpenJDK 11 because:
- Your application requires it: some applications may require a specific version of Java to run, and OpenJDK 11 may be the minimum version required for your application.
- Security and bug fixes: as an LTS version, OpenJDK 11 will receive security and bug fixes for longer, making it a more stable and secure choice for your applications.
- Performance improvements: OpenJDK 11 includes several performance improvements over previous versions, such as faster startup time and reduced memory footprint.
The guide will demonstrate how to install OpenJDK 11 on Ubuntu 22.04 Jammy Jellyfish or Ubuntu 20.04 Focal Fossa using the command line terminal.
Step 1: Update Ubuntu
To ensure that the installation process runs smoothly without any conflicts, updating the Ubuntu system to its latest version is recommended. This can be achieved by executing the following command in the terminal:
sudo apt update && sudo apt upgrade
The command will update the package lists and upgrade existing packages to their latest versions. It is important to note that this step may take some time, depending on the number of packages that need to be updated. Therefore, it is advised to wait until the process is completed before proceeding to the next step.
Step 2: Install OpenJDK
To install OpenJDK 11 on Ubuntu, there are several options available, with the most recommended one being through the default Ubuntu repository.
To check the available OpenJDK 11 packages, enter the following command in the terminal:
apt-cache search openjdk-11
The output will display all the available packages related to OpenJDK 11, including the Java Development Kit (JDK) and Java Runtime Environment (JRE).
To install OpenJDK 11 JRE (Java Runtime Environment), execute the following command:
sudo apt install openjdk-11-jre
Alternatively, if you need to develop Java applications, you can install the OpenJDK 11 JDK (Java Development Kit) by running the following command:
sudo apt install openjdk-11-jdk
There may be additional OpenJDK 11 packages available in the repository, such as the OpenJDK 11 source code or the OpenJFX package for building JavaFX applications. You can install them using the same approach by searching for the package name using
apt-cache search and then installing it using
sudo apt install.
How to Switch Alternative Java Versions
Once you have installed OpenJDK 11 on your Ubuntu system, you may want to switch to it as your default Java version. To do so, you can use the
update-alternatives command, which manages the symbolic links used for different Java versions.
To list all the available Java alternatives, including the newly installed OpenJDK 11, run the following command in the terminal:
sudo update-alternatives --config java
The command will output a list of available Java versions, including their paths and priority. You will be prompted to select the default Java version by typing the corresponding number and pressing the Enter key. In this case, you should select the number corresponding to OpenJDK 11.
After selecting the OpenJDK 11 version as the default, you can verify the change by running the following command:
This command will display the current default Java version, which should now be OpenJDK 11. If you need to switch back to any other installed Java versions, you can use the same process and select the appropriate number from the list.
In conclusion, installing OpenJDK 11 on Ubuntu can be done easily using the default Ubuntu repository. OpenJDK 11 is a long-term support version, making it a stable and secure choice for developers who require a reliable Java platform.
However, it’s worth noting that OpenJDK 17 is the latest version available, and developers should consider upgrading to it if possible. OpenJDK 17 offers new features, improvements, and bug fixes over OpenJDK 11, making it a more robust option for development. Upgrading to OpenJDK 17 can be done similarly to the installation of OpenJDK 11, using the default Ubuntu repository or other available installation methods.
These resources provide a wealth of information if you seek further information:
- OpenJDK 11 Documentation: JDK 11 (openjdk.org).
- Ubuntu Documentation on Java: Java – Community Help Wiki (ubuntu.com)
- OpenJDK Bug Database: System Dashboard – Java Bug System (openjdk.org)
- Java Tutorials by Oracle: The Java™ Tutorials (oracle.com)
- Java API Documentation: Overview (Java SE 11 & JDK 11 ) (oracle.com)
- OpenJDK 11 tag on Stack Overflow: https://stackoverflow.com/questions/tagged/openjdk-11
- OpenJDK tag on Stack Overflow: https://stackoverflow.com/questions/tagged/openjdk