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?
Usually you install the openjdk like this:
Maybe this is the problem. You can look this up at http://openjdk.java.net/install/index.html. If you do this you might have fixed this problem. But cant imagine why your command give this result.
I installed oracle-jdk8. If you need,
You can install openJDK with below command -
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 -
You can simply follow below steps
Download JDK 1.8 from https://repo.huaweicloud.com/java/jdk/8u202-b08/jdk-8u202-linux-x64.tar.gz
Extract it using tar -xvzf ~/Downloads/jdk-8u202-linux-x64.tar.gz ~/JDK-1.8
set JAVA_HOME using command export JAVA_HOME=~/JDK-1.8
set PATH using command export PATH=~/JDK-1.8/bin:$PATH
Use below URL for more details https://www.vultr.com/docs/how-to-manually-install-java-8-on-ubuntu-16-04/