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之后 切换版本,执行命令
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home/
export PATH=$JAVA_HOME/bin:$PATH
再执行java -version命令查看当前版本是否更改
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
网友评论