Install java8

 brew tap  homebrew/cask-versions
 brew cask install adoptopenjdk/openjdk/adoptopenjdk8

List available java versions

  /usr/libexec/java_home -V

List available java versions

  /usr/libexec/java_home -V

Select current java version

  export JAVA_HOME=`/usr/libexec/java_home -v 1.8`

Reference: https://stackoverflow.com/questions/21964709/how-to-set-or-change-the-default-java-jdk-version-on-os-x