Ubuntu – Install AdoptOpenJDK onto Ubuntu 18.04 LTS

javasoftware installation

I downloaded Java 11 in the form of OpenJDK from AdoptOpenJDK. From the tar.gz file I can extract a folder named jdk-11.0.3+7 with nested folders for bin, conf, lib, and so on. But no installer app found there.

➥ How should I install this downloaded Java release onto Ubuntu?

I can cd into the bin folder and execute commands like ./java --version. But I wonder if there is a usual routine for placing the Java implementation somewhere specific, and arranging environment variables, setting default path, etc. On macOS, an installer does all that for me automatically. As I newbie on Ubuntu, I'm uneducated.

Older Questions such as this one ask about using apt-get. My Question is not a duplicate, as here I am asking about downloads from AdoptOpenJDK rather than via package-installer such as apt-get.

enter image description here

Best Answer

Adoptium, formerly known as AdoptOpenJDK, provides a Debian / Ubuntu repository.

You can install using the package management system, which is much simpler than installing it manually.:

wget -qO - https://adoptopenjdk.jfrog.io/adoptopenjdk/api/gpg/key/public | sudo apt-key add -
sudo add-apt-repository --yes https://adoptopenjdk.jfrog.io/adoptopenjdk/deb/
sudo apt update
sudo apt install adoptopenjdk-8-hotspot  # Java 8 / HotSpot VM
sudo apt install adoptopenjdk-8-openj9   # Java 8 / OpenJ9 VM
sudo apt install adoptopenjdk-11-hotspot # Java 11 / HotSpot VM
sudo apt install adoptopenjdk-11-openj9  # Java 11 / OpenJ9 VM
sudo apt install adoptopenjdk-12-hotspot # Java 12 / HotSpot VM
sudo apt install adoptopenjdk-12-openj9  # Java 12 / OpenJ9 VM
sudo apt install adoptopenjdk-13-hotspot # Java 13 / HotSpot VM
sudo apt install adoptopenjdk-13-openj9  # Java 13 / OpenJ9 VM

You can switch between e.g. OpenJDK and AdoptOpenJDK using the following command.:

sudo update-alternatives --config java
Related Question