You and other students 2022-02-13 08:02:38 阅读数:618
Because the project needs , need jdk11 To run a project , But other projects are jdk1.8 Of , It is inconvenient to replace directly jdk, So you need to configure multiple on one machine jdk
download jdk11
File download address :https://download.java.net/java/GA/jdk11/13/GPL/openjdk-11.0.1_osx-x64_bin.tar.gz
Unzip the installation package ( The default installation location in the system :/Library/Java/JavaVirtualMachines/)
sudo tar -zxf openjdk-11.0.1_osx-x64_bin.tar.gz -C /Library/Java/JavaVirtualMachines/
verification
Configure environment variables
(1) ~/.bash_profile Modify environment variables
Replace according to the version installed by yourself
export JAVA_8_HOME=$(/usr/libexec/java_home -v1.8)
export JAVA_11_HOME=$(/usr/libexec/java_home -v11)
export JAVA_17_HOME=$(/usr/libexec/java_home -v17)
#alias Command dynamic switching JDK edition
alias jdk8="export JAVA_HOME=$JAVA_8_HOME"
alias jdk11='export JAVA_HOME=$JAVA_11_HOME'
alias jdk17='export JAVA_HOME=$JAVA_17_HOME'
perform source ~/.bash_profile
Make the above settings work
brew install jenv
To configure JEnv environment variable
echo 'export PATH="$HOME/.jenv/bin:$PATH"' >> ~/.bash_profile \
&&echo 'eval "$(jenv init -)"' >> ~/.bash_profile \
&&source ~/.bash_profile
/usr/libexec/java_home -V
Add directory to jenv Ongoing management
jenv add /Library/Java/JavaVirtualMachines/jdk1.8.0_101.jdk/Contents/Home
View added versions
jenv versions
6. Manual switching
jenv global 11.0
Reference resources :
https://www.cjavapy.com/article/91/
https://blog.csdn.net/aqzwss/article/details/54318921
copyright:author[You and other students],Please bring the original link to reprint, thank you. https://en.javamana.com/2022/02/202202130802362120.html