JDK version switch back

Input Terminal: / usr / libexec / java_home -V see two versions of the final installation directory:
the JDK 1.7: /Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk/Contents/Home
the JDK 1.8: / Library / the Java / JavaVirtualMachines / jdk1 .8.0_131.jdk / Contents / Home

An editing bash_profile: vi ~ / .bash_profile

Second, add the following:

# JDK1.7

export JAVA_7_HOME='/Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk/Contents/Home'

# JDK1.8

export JAVA_8_HOME='/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home'

# Default JDK version 1.7

export JAVA_HOME=$JAVA_7_HOME

# Alias ​​switching JDK versions

alias jdk7="export JAVA_HOME=$JAVA_7_HOME"

alias jdk8="export JAVA_HOME=$JAVA_8_HOME"

Third, the implementation of the entry into force command: source ~ / .bash_profile

Fourth, the best and then restart the computer under mac. I had not restart, it did not take effect test.

V. IMPLEMENTATION: java -version, see if it is version 1.7?
Execution: jdk8, then execute java -version, see if it is version 1.8?
So to achieve a switch back version.

ps: about = number can not have spaces

发布了18 篇原创文章 · 获赞 4 · 访问量 2万+

Guess you like

Origin blog.csdn.net/ostriches/article/details/93323775