下载
首先,从oracle官网下载JDK17:Java Downloads | Oracle
JDK默认安装在/Library/Java目录下,打开访达,通过shift+command+g直达文件,如果安装成功,/Library/Java/JavaVirtualMachines目录下,会有两个JDK:
配置
接下来,打开终端,输入vim ~/.bash_profile,编辑配置文件
在配置文件中,配置成以下内容
export M2_HOME=/Users/Environment/maven/apache-maven-3.8.6
export PATH=$PATH:$M2_HOME/bin
export PATH=$PATH:/usr/local/mysql/bin
export PATH=$PATH:/usr/local/mysql/support-files
source ~/.bashrc
#JDK 路径
export JAVA_17_HOME='/Library/Java/JavaVirtualMachines/jdk-17.jdk/Contents/Home'
export JAVA_11_HOME='/Library/Java/JavaVirtualMachines/zulu-11.jdk/Contents/Home'
# default JDK,默认的jdk设置
export JAVA_HOME=$JAVA_11_HOME
# 切换jdk设置
alias jdk17="export JAVA_HOME=$JAVA_17_HOME"
alias jdk11="export JAVA_HOME=$JAVA_11_HOME"
~
输入完成,按esc键,输入:wq保存退出后执行命令:source ~/.bash_profile