How can I install OpenJDK on Ubuntu 16.04?

84,345

Solution 1

had the same problem too.. but i solved it with these commands:

sudo add-apt-repository ppa:openjdk-r/ppa  
sudo apt-get update   
sudo apt-get install openjdk-7-jre  

Solution 2

The one I did on 16.04 was:

For OpenJDK 8.X

sudo apt install openjdk-8-jre

For OpenJDK 9.X

sudo apt install openjdk-9-jre

Note: There was no openjdk-6-jre nor openjdk-7-jre for me on Ubuntu 16.04. Also there is NO need to install Oracle JDK (Actually OpenJDK is much better than Oracle one for me).

Solution 3

Some feedback with 16.04... If you are installing as part of a "software script" package, you always have to check which version of Java the programs support first.

For example, using openjdk-8-jre (newer version) on the install script.

sudo apt-get update && sudo apt-get upgrade
sudo apt-get install openjdk-8-jre
Share:
84,345

Related videos on Youtube

Hakam El Assouad
Author by

Hakam El Assouad

Updated on September 18, 2022

Comments

  • Hakam El Assouad
    Hakam El Assouad over 1 year

    Since I upgraded to the latest version of Ubuntu, I cannot install the Java OpenJDK package needed to compile Android custom ROMs. When I run sudo apt-get install openjdk-7-jdk, the following error appears:

    Reading package lists... Done Building dependency tree        Reading
    state information... Done Some packages could not be installed. This
    may mean that you have requested an impossible situation or if you are
    using the unstable distribution that some required packages have not
    yet been created or been moved out of Incoming. The following
    information may help to resolve the situation:
    
    The following packages have unmet dependencies:  openjdk-7-jdk :
     Depends: openjdk-7-jre (= 7u51-2.4.6-1ubuntu4) E: Unable to correct
     problems, you have held broken packages.
    

    How do I fix this problem?

    • Organic Marble
      Organic Marble about 8 years
      I just installed openjdk-8-jdk and openjdk-8-jre on 16.04, maybe try them?
    • Alexiy
      Alexiy about 8 years
      If you fail to install Openjdk, install Oracle jdk by following good instructions here askubuntu.com/questions/521145/…
    • Hakam El Assouad
      Hakam El Assouad about 8 years
      i guess not all packages are downloaded while installing system..because i haven't these errors on 14.04..