赞
踩
选择和自己电脑对应版本的安装:
Java Downloads | Oracle
dmg的安装方式,无需注意特别,默认安装即可。
原理:
通过linux alias命令给自定义命令起别名并能通过别名来执行自定义命令。
修改 vim ~/.bash_profile
# Java config
export JAVA_8_HOME="/Library/Java/JavaVirtualMachines/jdk1.8.0_271.jdk/Contents/Home"
export JAVA_11_HOME="/Library/Java/JavaVirtualMachines/jdk-11.0.17.jdk/Contents/Home"
# config alias
alias jdk8="export JAVA_HOME=$JAVA_8_HOME"
alias jdk11="export JAVA_HOME=$JAVA_11_HOME"
# config default jdk
export JAVA_HOME=$JAVA_8_HOME
export PATH="$JAVA_HOME:$PATH"
使编译生效:
source ~/.bash_profile
测试:
lianggao@LiangdeMacBook-Pro ~ % java -version
java version "1.8.0_271"
Java(TM) SE Runtime Environment (build 1.8.0_271-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.271-b09, mixed mode)
lianggao@LiangdeMacBook-Pro ~ % jdk11
lianggao@LiangdeMacBook-Pro ~ % java -version
java version "11.0.17" 2022-10-18 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.17+10-LTS-269)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.17+10-LTS-269, mixed mode)
打开module设置,设置SDK
设置项目的sdk版本
设置模块的sdk
java compiler设置
参考
https://blog.csdn.net/oampZuo12345/article/details/77620744
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。