How to Install OpenJDK 11 on Ubuntu 20.04 LTS
You’ll get Java 11 up and running on a fresh Ubuntu 20.04 install using three different ways: the official Ubuntu repository, a trusted PPA, or a manual tarball extraction. Pick the method that matches how picky you are about updates and package sources.
Install OpenJDK 11 from the Ubuntu repo
- Update your package index – this makes sure apt knows what versions are available.
sudo apt update
- Grab the JDK package. The repository ships a clean, security‑patched build that will stay in sync with Ubuntu’s regular updates.
sudo apt install openjdk-11-jdk
- Verify the installation; java -version should print something like “openjdk version "11.0.x””. This step confirms the binaries are on your $PATH.
Why this works: Ubuntu 20.04 ships OpenJDK 11 as its default Java, so you get a tested stack without extra third‑party code.
Install OpenJDK 11 via a PPA (if you need newer patches)
Some people like to chase the very latest security fixes that land in the upstream builds before Ubuntu rolls them out. The “Linux Uprising” PPA is a popular, well‑maintained source.
- Add the PPA – it’s just another apt repository, but be aware you’re trusting external maintainers.
sudo add-apt-repository ppa:linuxuprising/java
- Refresh the index again.
sudo apt update
- Install the JDK from the PPA.
sudo apt install openjdk-11-jdk
Reality check: I once added a random PPA for a graphics driver, and it pulled in an older libssl that broke my Spring Boot apps. Stick to well‑known PPAs or just use the distro packages unless you have a compelling reason.
Install OpenJDK 11 from the official tar.gz archive
When you need an exact build (maybe for reproducible builds) or want to avoid any package manager, download the binary directly from AdoptOpenJDK/Adoptium.
- Grab the latest tarball – replace x.y.z with the current version number.
wget https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.x.y.z%2Bz/OpenJDK11U-jdk_x64_linux_hotspot_11.x.y.z.tar.gz
- Extract it into /opt. This location is conventional for manually managed software.
sudo tar -xzf OpenJDK11U-jdk_x64_linux_hotspot_11*.tar.gz -C /opt/
- Create a symlink so the system can find java without altering your PATH in every shell.
sudo ln -s /opt/jdk-11*/bin/java /usr/local/bin/java11
- Test it:
java11 -version
Why bother: The archive method gives you full control over which build you run, but you’ll have to manage updates yourself. If you’re comfortable with manual maintenance, this is the cleanest approach.
Pick the route that feels right for your workflow. The repo install is quick and safe; the PPA gives a bit more bleeding‑edge support at the cost of extra trust; the archive method is for the control freaks who love to keep everything in their own hands.