How can you change the default version of Java on a mac?
If still u are not able to set it. using this command.
export JAVA_HOME=/usr/libexec/java_home -v 1.8
/usr/libexec/java_home -v 1.8
then you have to use this one.
export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)
$(/usr/libexec/java_home -v 1.8)
it will surely work.