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


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM