How to install Java on Ubuntu 18.04 and derived distributions

Java logo

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.

The content of the article adheres to our principles of editorial ethics. To report an error click here.

5 comments, leave yours

Leave a Comment

Your email address will not be published. Required fields are marked with *



  1. Responsible for the data: AB Internet Networks 2008 SL
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.

  1.   Lorenzo Javier Brito Estrada said

    I hope it downloads

  2.   JOSE LARRAENZA said

    Thank you very much.
    sudo apt install openjdk-8-jdk
    it worked very well.

  3.   Joaquin said

    Ami is downloading I hope it works

  4.   Frederick Parrotta said


    The jdk does not install me because it tells me the following

    "E: The openkdj-11-jdk package could not be located"

    I've looked for different ways but none of them work for me, and I don't know what to do now

    1.    BombLab said

      If that is what you have written you have changed the letters. It is:
      openjdk not openkdj