me too.
if already set $JAVA_HOME, /usr/libexec/java_home -v {{VERSION}} return $JAVA_HOME
so i just vim ~/.zprofile
#alias setJDK7='unset JAVA_HOME;export JAVA_HOME=`/usr/libexec/java_home -v 1.7`'
alias setJDK8='unset JAVA_HOME;export JAVA_HOME=`/usr/libexec/java_home -v 1.8`'
alias setJDK11='unset JAVA_HOME;export JAVA_HOME=`/usr/libexec/java_home -v 11`'