Follow these steps to change the default version of Java on mac:
Open the Terminal
Confirm that you have JDK by typing “which java”. It should show something like /usr/bin/java.
Check you have the needed version of Java, by typing “java -version”.
Set JAVA_HOME doing this command in Terminal: export JAVA_HOME=/Library/Java/Home
echo $JAVA_HOME on Terminal to validate the path
You should now be able to run your application