Maven JAVA_HOME 环境变量未正确定义,但它是

我在 Windows 上设置 Maven,我认为一切设置正确,但我在运行时仍然收到错误JAVA_HOME 环境变量未正确定义"<​​/p>

I'm setting up Maven on Windows and I think everything is set up correctly, but I'm still getting the error "The JAVA_HOME environment variable is not defined correctly" when I run

mvn --version

在我的环境变量中,我有以下内容:

In my environment variables, I have the following:

用户变量

  • M2_HOME 是 C:apache-maven-3.6.3
  • MAVEN_HOME 是 C:apache-maven-3.6.3
  • JAVA_HOME 是 C:Program FilesJavajdk-11.0.2in

系统变量

  • JAVA_HOME 是 C:Program FilesJavajdk-11.0.2in

在系统变量中,在我的路径变量中,我有:

Inside System Variables, in my Path variable, I have:

  • C:Program Files (x86)Common FilesOracleJavajavapath

  • C:Program Files (x86)Common FilesOracleJavajavapath

C:ProgramDataOracleJavajavapath

C:ProgramDataOracleJavajavapath

C:Program FilesJavajdk-11.0.2in

C:Program FilesJavajdk-11.0.2in

C:apache-maven-3.6.3in

C:apache-maven-3.6.3in

似乎无法弄清楚这些环境变量出了什么问题,以至于 Maven 会给我这个错误.任何帮助将不胜感激!

Can't seem to figure out what's wrong with these environment variables such that Maven would be giving me that error. Any help would be greatly appreciated!

推荐答案

你的 JAVA_HOME 不正确.JAVA_HOME 应该是C:Program FilesJavajdk-11.0.2"

Your JAVA_HOME is incorrect. JAVA_HOME should be "C:Program FilesJavajdk-11.0.2"

请记住在重置 JAVA_HOME 环境后重新打开新控制台以应用新值.

Remember to reopen new console after reset JAVA_HOME environment to apply new value.

相关文章