1.打开terminal
/usr/libexec/java_home -V
2.查看当前java版本
java -version
3.切换到jdk1.8
open ~/.bash_profile
加上这两句
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_211.jdk/Contents/Home
export JAVA_HOME
4.更新配置
source ~/.bash_profile
qiang@xiaocaidembp ~$ source ~/.bash_profile
5.查看java版本
java -version