Celeb Glow
news | March 18, 2026

How to install JDK8 on Ubuntu 16?

I needed JDK 8 for Bazel. I ran sudo apt-get install openjdk-8* on a freshly built Ubuntu 16.04.02 machine, but after installation update-alternatives --config java show two paths:

/usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java
/usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java

I purged opensdk-8* and then installed apt-get openjdk-9* but the outcome was the same.

How do I get JDK 8?

3 Answers

Usually you install the openjdk like this:

sudo apt-get install openjdk-8-jdk

Maybe this is the problem. You can look this up at . If you do this you might have fixed this problem. But cant imagine why your command give this result.

2

I installed oracle-jdk8. If you need,

sudo add-apt-repository ppa:webupd8team/java && sudo apt update
sudo apt install oracle-java8-installer

You can install openJDK with below command -

sudo apt-get install openjdk-8-jdk

OR You can also look at option to install Oracle Java 8. Detailed instructions are updated in the blog here. You can also use below commands for a quick answer -

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt install oracle-java8-set-default
javac -version

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy