The JAVA_HOME environment variable is not defined correctly,this environment variable is needed to r

Posted 一只猪的思考

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了The JAVA_HOME environment variable is not defined correctly,this environment variable is needed to r相关的知识,希望对你有一定的参考价值。

今天使用mvn命令的时候发现如下报错

The JAVA_HOME environment variable is not defined correctly,this environment variable is needed to run this program

于是用java -v 命令查看jdk环境是否配置好
出现的却是openjdk的环境,并非本人所配环境
但当我使用
vim ~/.bash_profile的时候却发现环境配置并没有问题

于是我想看看是不是文件没重新加载
于是使用source ~/.bash_profile后发现
mvn命令有可以使用了
恩?莫非是发生灵异事件了???
但后面查资料发现是应为每次关闭terminal后文件变失效了
需要

vim .zshrc
source ~/.bash_profile
mvn -v

才可以每次打开控制台时生效
或是直接在.zshrc文件中配置

以上是关于The JAVA_HOME environment variable is not defined correctly,this environment variable is needed to r的主要内容,如果未能解决你的问题,请参考以下文章

配置Maven时报错The JAVA_HOME environment variable is not defined correctly,this environment解决方法汇总

新手打开Android Studio The environment variable java_home,求大神帮帮忙

The JAVA_HOME environment variable is not defined correctly的错误

启动tomcat提示Neither the JAVA_HOME nor the JRE_HOME environment variable is defined

解决Linux下启动Tomcat遇到Neither the JAVA_HOME nor the JRE_HOME environment variable is defined

The JAVA_HOME environment variable is not defined correctly,this environment variable is needed to r