In Linux (Debian/Ubuntu) this can be solved by selecting a Java 1.8 SDK in
sudo update-alternatives --config javac
Changing JAVA_HOME
env variable directly does not seem to have any effect.
EDIT: responding to the comments: This probably has something to do with the fact that new Debian (and apparently Ubuntu) Java installations through the package manager do not use the JAVA_HOME
enviroment variable to determine the location of the JRE. See this and this post for more info.