官方下载地址
https://www.oracle.com/cn/java/technologies/downloads/
这个是官方新发布的适配了M1、M2芯片的ARM64版本的jdk8,再也不用去第三方下载了,也不用满世界的去找第三方jdk缺少的jar包了,而且更快更强!!
可以下载免安装版, 这样就可以配置多个版本的jdk了,配置如下
m@mdeMacBook-Pro ~ % vim .zprofile# JDK 配置export JAVA_8_HOME=/Users/m/dev_tools/jdk/jdk1.8.0_381.jdk/Contents/Homeexport JAVA_11_HOME=/Users/m/dev_tools/jdk/jdk-11.0.20.jdk/Contents/Homeexport JAVA_17_HOME=/Users/m/dev_tools/jdk/jdk-17.0.8.jdk/Contents/Home# 默认JDK版本export JAVA_HOME=$JAVA_8_HOME# 多版本切换(取了别名,更方便切换)alias jdk8="export JAVA_HOME=$JAVA_8_HOME"alias jdk11="export JAVA_HOME=$JAVA_11_HOME"alias jdk17="export JAVA_HOME=$JAVA_17_HOME"export PATH=$JAVA_HOME/bin:$PATH
使配置文件生效
m@mdeMacBook-Pro ~ % source /etc/profile ~/.zprofile
切换jdk版本
m@mdeMacBook-Pro ~ % jdk11m@mdeMacBook-Pro ~ % java -versionjava version "11.0.20" 2023-07-18 LTSJava(TM) SE Runtime Environment 18.9 (build 11.0.20+9-LTS-256)Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.20+9-LTS-256, mixed mode)m@mdeMacBook-Pro ~ % jdk17m@mdeMacBook-Pro ~ % java -versionjava version "17.0.8" 2023-07-18 LTSJava(TM) SE Runtime Environment (build 17.0.8+9-LTS-211)Java HotSpot(TM) 64-Bit Server VM (build 17.0.8+9-LTS-211, mixed mode, sharing)m@mdeMacBook-Pro ~ % jdk8m@mdeMacBook-Pro ~ % java -versionjava version "1.8.0_381"Java(TM) SE Runtime Environment (build 1.8.0_381-b09)Java HotSpot(TM) 64-Bit Server VM (build 25.381-b09, mixed mode)
idea中配置