Apple has removed Java's preference management from its latest upgrade, so it is now difficult to manage the JDK version on Mac systems. I recently noticed that after loading the jdk8 want to change back, online tips are not good to use AH. After a lot of Google, I found a simple way to share.
function Setjdk () { if [$#-ne 0]; then removefrompath '/system/library/frameworks/javavm.framework/home/bin ' if [-N "${java_home+x}"]; then removefrompath $JAVA _home fi export java_home= '/usr/libexec/java_ home-v [email protected] ' export path= $JAVA _home/bin: $PATH fi} function Removefrompath () { Export path=$ ( echo $PATH | SED-E-E "s;:$1;;"-E "s;$1:?;;") }SETJDK 1.7
Please put the above code into the bash_profile file after saving remember to play the command ~/.bash_profile.
The above is the result of the author's pro-test, if there is a problem please leave a message ~
Original address
Mac computer JDK version switch