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

Implementing coexistence of multiple Java versions under mac

王林
Release: 2020-05-12 16:25:35
forward
3537 people have browsed it

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
Copy after login

2. Open the .bash_profile file

$ open .bash_profile
Copy after login

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"
Copy after login

4, and then execute the .bash_profile file

$ source ~/.bash_profile
Copy after login

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!

Related labels:
source:cnblogs.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template