xlinsist xlinsist - 11 months ago 89
Java Question

JDK Version inconsistent

My os is Ubuntu 16.04 LTS.

$ cat /etc/profile # part content of this file
export JAVA_HOME
export JRE_HOME
export PATH

$ echo $JAVA_HOME

$ java -version
java version "1.7.0_79"
Java(TM) SE Runtime Environment (build 1.7.0_79-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)

$ ls /usr/local/java/
jdk1.7.0_79/ jdk1.8.0_101/

Why is my java version still jdk7?


Ubuntu has ability to work with multiple java versions. In your case, it just means that it has both JDK 7 and JDK 8 installed in your system but is using JDK 7.

To switch from one java version to another, you can use sudo update-alternatives --config java. This will list all JDKs installed in your system, just enter the number corresponding to JDK 8 and it should switch to JDK 8.