OpenJDK 11 is a free, open-source implementation of the Java Platform used to run and develop Java applications. As a Long-Term Support (LTS) release, it remains widely deployed for enterprise software, build tools, and server-side applications that require a stable, maintained Java runtime. By the end of this guide, you will have OpenJDK 11 installed on Ubuntu using the default APT repository, with the ability to manage multiple Java versions and verify your installation.
Compare OpenJDK LTS Releases for Ubuntu
Before installing, confirm that OpenJDK 11 matches your project requirements. The table below compares LTS Java versions available in Ubuntu’s default repositories.
| Java Version | LTS Support Until | Choose It When | Trade-offs |
|---|---|---|---|
| OpenJDK 8 | December 2030 (community) | Legacy applications, older frameworks like Spring 4.x, or vendor-certified deployments requiring Java 8 | Missing modern language features (no var, no records, no virtual threads); some libraries dropping Java 8 support |
| OpenJDK 11 | September 2027 (community) | Enterprise applications, build servers, projects needing stable LTS with module system support and modern TLS | Lacks Java 21 features; some newer frameworks require 17+ as minimum |
| OpenJDK 17 | September 2029 (community) | Spring Boot 3.x, Jakarta EE 10+, or workloads benefiting from records and sealed classes | Missing virtual threads and newer pattern matching features from Java 21 |
| OpenJDK 21 | September 2031 (community) | New projects, high-concurrency applications using virtual threads, or development requiring the latest stable LTS features | Newest LTS release; verify all dependencies support Java 21 before migrating production workloads |
Choose OpenJDK 11 when your application explicitly requires Java 11, your CI/CD pipeline targets this version, or you need the LTS stability without migrating to Java 17. For new projects without legacy constraints, consider starting with OpenJDK 17 instead.
Update Ubuntu Before OpenJDK 11 Installation
First, update your Ubuntu system to ensure all packages are current and avoid potential conflicts during installation:
sudo apt update
sudo apt upgrade
The first command refreshes your package index, while the second upgrades installed packages to their latest versions. Depending on how many packages require updates, this process may take a few minutes.
Install OpenJDK 11 on Ubuntu
Ubuntu’s default repositories include OpenJDK 11 packages, making installation straightforward without adding external sources. Before installing, you can view the available OpenJDK 11 packages:
apt-cache search openjdk-11
This command displays all packages related to OpenJDK 11. You should see output similar to:
openjdk-11-jdk - OpenJDK Development Kit (JDK) openjdk-11-jdk-headless - OpenJDK Development Kit (JDK) (headless) openjdk-11-jre - OpenJDK Java runtime, using Hotspot JIT openjdk-11-jre-headless - OpenJDK Java runtime, using Hotspot JIT (headless) openjdk-11-source - OpenJDK Development Kit (JDK) source files
Install JRE or JDK
Choose the package that matches your needs. If you only need to run Java applications, install the Java Runtime Environment (JRE):
sudo apt install openjdk-11-jre
Alternatively, if you plan to develop Java applications or use build tools like Apache Maven, install the full Java Development Kit (JDK), which includes the JRE plus development tools:
sudo apt install openjdk-11-jdk
Verify the Installation
After installation completes, verify that Java is accessible by checking the installed version:
java --version
You should see output confirming OpenJDK 11 is installed:
openjdk 11.0.x 20xx-xx-xx OpenJDK Runtime Environment (build 11.0.x+x-post-Ubuntu-xubuntuxx.xx) OpenJDK 64-Bit Server VM (build 11.0.x+x-post-Ubuntu-xubuntuxx.xx, mixed mode, sharing)
If you installed the JDK, also verify the Java compiler is available:
javac --version
javac 11.0.x
Manage Multiple Java Versions
If you have multiple Java versions installed on your system, Ubuntu provides the update-alternatives command to switch between them. This is particularly useful when different projects require different Java versions.
Switch Between Java Versions
To view all installed Java versions and select one as the system default, run:
sudo update-alternatives --config java
This command displays an interactive menu showing all available Java installations with their paths and priorities:
There are 2 choices for the alternative java (providing /usr/bin/java). Selection Path Priority Status ------------------------------------------------------------ * 0 /usr/lib/jvm/java-17-openjdk-amd64/bin/java 1711 auto mode 1 /usr/lib/jvm/java-11-openjdk-amd64/bin/java 1111 manual mode 2 /usr/lib/jvm/java-17-openjdk-amd64/bin/java 1711 manual mode Press <enter> to keep the current choice[*], or type selection number:
Enter the selection number corresponding to OpenJDK 11 and press Enter. After making your selection, verify the change with java --version.
Set JAVA_HOME Environment Variable
Many Java applications and build tools require the JAVA_HOME environment variable to locate your Java installation. For detailed instructions on configuring this variable persistently, see our guide on setting the Java environment path in Ubuntu.
As a quick reference, you can find the path to your OpenJDK 11 installation with:
dirname $(dirname $(readlink -f $(which java)))
On 64-bit Ubuntu systems with OpenJDK 11 as the active version, this returns:
/usr/lib/jvm/java-11-openjdk-amd64
Remove OpenJDK 11
If you no longer need OpenJDK 11, remove it along with any automatically installed dependencies:
sudo apt remove openjdk-11-jdk openjdk-11-jre
sudo apt autoremove
The first command removes the main OpenJDK 11 packages, while apt autoremove cleans up any orphaned dependencies that were installed alongside Java but are no longer needed.
After removal, verify that Java is no longer available or has switched to another installed version:
java --version
If no other Java versions are installed, this command returns an error confirming removal. If another version remains, the output shows which Java is now active.
Conclusion
You now have OpenJDK 11 installed on Ubuntu and configured as your Java runtime. With the update-alternatives system, you can easily switch between multiple Java versions as needed for different projects. For Java development workflows, consider installing Apache Maven as a build tool, or explore OpenJDK 17 if your projects require a more recent LTS release.