If you want to use specific version of Java when multiple JDKs are installed, just setting JAVA_HOME may not work.
You need to use sudo update-alternatives --config java
to set default Java.
Refer to https://askubuntu.com/questions/121654/how-to-set-default-java-version.