Mac上Java版本是1.7.0_79
java version "1.7.0_79"
Java(TM) SE Runtime Environment (build 1.7.0_79-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)
luanshiweideMacBook-Air:~ luanshiwei$
下載并安裝1.8之后 切換版本陶缺,執(zhí)行命令
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home/
export PATH=$JAVA_HOME/bin:$PATH
再執(zhí)行java -version命令查看當(dāng)前版本是否更改
java version "1.8.0_40"
Java(TM) SE Runtime Environment (build 1.8.0_40-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.40-b25, mixed mode)
如果想永久生效垃杖,那就把命令加入到你的profile文件中。
echo 'export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home/' >> ~/.bash_profile
source ~/.bash_profile