Mac系统查看maven版本时出现The JAVA_HOME environment variable is not defined correctly, this environment variable is needed to run this program.
环境:Mac系统、jdk1.8、maven3.8.4
终端输入mvn -v出现:
The JAVA_HOME environment variable is not defined correctly,
this environment variable is needed to run this program.
解决方法:
修改环境变量
- 终端打开~/.bash_profile
vim ~/.bash_profile
- 添加
export JAVA_HOME=$(/usr/libexec/java_home)
- 修改配置前:
- 修改配置后:
- 更新~/.bash_profile
source ~/.bash_profile