最终效果图:
adudubushiamumudeMacBook-Pro-2:~ admin$ jdk6
adudubushiamumudeMacBook-Pro-2:~ admin$ java -version
java version "1.6.0_65"
Java(TM) SE Runtime Environment (build 1.6.0_65-b14-468)
Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-468, mixed mode)
adudubushiamumudeMacBook-Pro-2:~ admin$ jdk7
adudubushiamumudeMacBook-Pro-2:~ admin$ java -version
java version "1.7.0_80"
Java(TM) SE Runtime Environment (build 1.7.0_80-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed mode)
adudubushiamumudeMacBook-Pro-2:~ admin$ jdk8
adudubushiamumudeMacBook-Pro-2:~ admin$ java -version
java version "1.8.0_152"
Java(TM) SE Runtime Environment (build 1.8.0_152-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.152-b16, mixed mode)
adudubushiamumudeMacBook-Pro-2:~ admin$ jdk9
adudubushiamumudeMacBook-Pro-2:~ admin$ java -version
java version "9.0.1"
Java(TM) SE Runtime Environment (build 9.0.1+11)
Java HotSpot(TM) 64-Bit Server VM (build 9.0.1+11, mixed mode)
adudubushiamumudeMacBook-Pro-2:~ admin$
adudubushiamumudeMacBook-Pro-2:~ admin$ jdk10
adudubushiamumudeMacBook-Pro-2:~ admin$ java -version
java version "10" 2018-03-20
Java(TM) SE Runtime Environment 18.3 (build 10+46)
Java HotSpot(TM) 64-Bit Server VM 18.3 (build 10+46, mixed mode)
1. open .bash_profile
##JDK配置##
JAVA_6_HOME=$(/usr/libexec/java_home -v 1.6)
JAVA_7_HOME=$(/usr/libexec/java_home -v 1.7)
JAVA_8_HOME=$(/usr/libexec/java_home -v 1.8)
JAVA_9_HOME=$(/usr/libexec/java_home -v 9)
JAVA_10_HOME=$(/usr/libexec/java_home -v 10)
##默认JDK8,毕竟成熟嘛,JDK9才刚刚开始嘛,我去JDK10都出了,计划每半年一个版本##
export JAVA_HOME=$JAVA_8_HOME
alias jdk6="export JAVA_HOME=$JAVA_6_HOME"
alias jdk7="export JAVA_HOME=$JAVA_7_HOME"
alias jdk8="export JAVA_HOME=$JAVA_8_HOME"
alias jdk9="export JAVA_HOME=$JAVA_9_HOME"
alias jdk10="export JAVA_HOME=$JAVA_10_HOME"
PATH=$PATH:$JAVA_HOME
2.source .bash_profile
3.然后,没有然后了,大工告成了!
温馨提醒:软件自己去Oracle官网去下载!!!
http://www.oracle.com/technetwork/java/javase/archive-139210.html