We have recently received the latest version of Ubuntu LTS on our computers, Ubuntu 18.04, a version that comes with many programs and options by default but some add-ons or tools such as the Java package, are still not installed by default in the distribution. And that means that it is not present in the distributions that are created from Ubuntu 18.04 either.
Here we explain how to install Java in your distribution be Ubuntu 18.04 or it is any of the many distributions that are based on this distribution.
There are two ways to install Java in Ubuntu: the first one is through external repositories and the second option is through the free alternative which is becoming more and more popular among Ubuntu users.
To install Java via external repositories We have to open the terminal and execute the following commands:
sudo add-apt-repository ppa:webupd8team/java sudo apt update sudo apt-get install oracle-java8-set-default
or change the last line to the following:
sudo apt-get install oracle-java9-set-default
This will install the last two official versions of Java in our Ubuntu, but Java belongs to Oracle and that means that it remains proprietary even if it is freely distributed. To change this, we can choose to have the free alternative to Java using OpenJDK packages, a totally free version of Java. These packages are in the official Ubuntu repositories, so we can install it via Ubuntu Software Center or we have to open the terminal and execute the following:
sudo apt-get install openjdk-11-jdk
sudo apt install openjdk-9-jdk
sudo apt install openjdk-8-jdk
This will install OpenJDK and allow us to run any code or program that needs Java to function on Ubuntu 18.04, such as the RENTA application of the Tax Agency or as an auxiliary tool to create smartphone apps.