Home >Operation and Maintenance >Mac OS >Implementing coexistence of multiple Java versions under mac

Implementing coexistence of multiple Java versions under mac

王林
王林forward
2020-05-12 16:25:353536browse

Implementing coexistence of multiple Java versions under mac

1. Environment

macOS High Sierra (Version: 10.13.6)

MacBook Air (13-inch, Early 2015)

2. Solution

1. Create a new .bash_profile file

$ touch .bash_profile

2. Open the .bash_profile file

$ open .bash_profile

3. The solution here is the coexistence of java8 and java11 problem, so enter the following code in the .bash_proflie file

export JAVA_8_HOME='/Library/Java/JavaVirtualMachines/jdk1.8.0_221.jdk/Contents/Home'
export JAVA_11_HOME='/Library/Java/JavaVirtualMachines/jdk-11.0.2.jdk/Contents/Home'
# 默认 jdk11
export JAVA_HOME=$JAVA_11_HOME
   
# 动态切换版本
alias jdk8="export JAVA_HOME=$JAVA_8_HOME"
alias jdk11="export JAVA_HOME=$JAVA_11_HOME"

4, and then execute the .bash_profile file

$ source ~/.bash_profile

The above is the detailed content of Implementing coexistence of multiple Java versions under mac. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:cnblogs.com. If there is any infringement, please contact admin@php.cn delete