Solve the Mac version coexistence issues under multi-java

First, the system environment

 

macOS High Sierra (Version: 10.13.6)

MacBook Air (13-inch, Early 2015)

 

Second, the solution step

 

1. Create a new file .bash_profile
$ touch .bash_profile
 
2. Open the file .bash_profile
$ open .bash_profile 
 
3. I resolve is java8 and java11 coexistence problems, so enter the following code in the file .bash_proflie
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. Then execute .bash_profile file
$ source ~/.bash_profile
  
ps:
1. Method path query terminal jdk 
$ /usr/libexec/java_home -V
 
2. The process .bash_profile had appeared: permission denied problem, the problem may be due to small errors in the code have caused, checked that my problem is because single quotes are Chinese encoding, modify save run successfully, jdk can free to switch.  

Guess you like

Origin www.cnblogs.com/comedian-cd/p/11493813.html