How can I install OpenJDK on Ubuntu 16.04?

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  

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).


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