OpenJDK (Open Java Development Kit) is a free and open-source implementation of the Java Platform, Standard Edition (Java SE).
Before you begin, let’s update the apt package index:
sudo apt update
Now let’s install it (it can take a few minutes as there is almost 1GB to download)
sudo apt install default-jdk
And let’s test it…
java --version