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.

image


解决方法:

修改环境变量

  • 终端打开~/.bash_profile
vim ~/.bash_profile
  • 添加
export JAVA_HOME=$(/usr/libexec/java_home)

  • 修改配置前:

image


  • 修改配置后:

image

  • 更新~/.bash_profile
source ~/.bash_profile

查看maven版本--Get

image

posted @ 2022-03-05 16:07  递茶大户  阅读(3240)  评论(0编辑  收藏  举报