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