错误:JAVA_HOME被设置为无效的目录。

时间:2021-10-09 23:06:18

I am trying to get maven installation to work but I am always getting this error

我正在尝试让maven安装工作,但我总是得到这个错误。

C:\Windows\System32>mvn --version
Error: JAVA_HOME is set to an invalid directory.
JAVA_HOME = "C:\Program Files\Java\jdk1.7.0_51;"
Please set the JAVA_HOME variable in your environment to match the location of your Java installation.

C:\Windows\ System32系统> mvn——版本错误:JAVA_HOME被设置为一个无效的目录。JAVA_HOME = " C:\ Program Files \ Java \ jdk1.7.0_51;”请在您的环境中设置JAVA_HOME变量,以匹配Java安装的位置。

I know that the error says every thing but I have tried everything here. I have the following setting:

我知道这个错误说明了一切,但我已经尝试过了。我有如下设置:

System Variables:

系统变量:

M2_HOME: C:\Program Files\Apache Software Foundation\apache-maven-3.3.3

M2_HOME:\ apache-maven-3.3.3 C:\Program Files\Apache软件基础

M2: %M2_HOME%\bin

M2:% M2_HOME % \ bin

JAVA_HOME: C:\Program Files\Java\jdk1.7.0_51

JAVA_HOME:C:\Program Files\Java\ jdk1.7.0_51

I added the whole path maybe it is interested someone. please take a look at the last part.

我加了整条路,也许有人感兴趣。请看最后一部分。

Path:

路径:

C:\Program Files\Java\jdk1.7.0_51\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\MiKTeX 2.9\miktex\bin\x64\;C:\Program Files\TortoiseSVN\bin;C:\Program Files (x86)\Heroku\bin;C:\Program Files (x86)\git\cmd;%M2%;%JAVA_HOME%\bin;

Path interested part:

路感兴趣的部分:

%M2%;%JAVA_HOME%\bin;

I have tried it by deleting the %JAVA_HOME%\bin; too but it does not work since I have this path by the SDK installation at the start of the path C:\Program Files\Java\jdk1.7.0_51\bin

我已经尝试过删除%JAVA_HOME%\bin;但它不工作因为我有这个路径的SDK安装的路径C:\Program Files\Java\ jdk1.7.0_51 \ bin

I have tried to add the setting to the user variables and it does not work.

我尝试将设置添加到用户变量中,但它不起作用。

4 个解决方案

#1


6  

JAVA_HOME = "C:\Program Files\Java\jdk1.7.0_51;"

JAVA_HOME = " C:\ Program Files \ Java \ jdk1.7.0_51;”

Maven says that there is a semi-colon after the directory name in the JAVA_HOME environment variable. Remove the semi-colon.

Maven表示,在JAVA_HOME环境变量中,目录名后面有一个分号。删除分号。

#2


0  

you shoud have both maven and java home defined in the same System Variable ...

您必须在相同的系统变量中定义maven和java home。

#3


0  

Try Rename M2_HOME at MAVEN_HOME Also change M2: %MAVEN_HOME%\bin

尝试在MAVEN_HOME重新命名M2_HOME,也可以更改M2: %MAVEN_HOME%\bin。

#4


0  

For me, the trick is to close and open another CMD window, to check if ir worked

对我来说,诀窍就是关闭并打开另一个CMD窗口,以检查ir是否有效。

#1


6  

JAVA_HOME = "C:\Program Files\Java\jdk1.7.0_51;"

JAVA_HOME = " C:\ Program Files \ Java \ jdk1.7.0_51;”

Maven says that there is a semi-colon after the directory name in the JAVA_HOME environment variable. Remove the semi-colon.

Maven表示,在JAVA_HOME环境变量中,目录名后面有一个分号。删除分号。

#2


0  

you shoud have both maven and java home defined in the same System Variable ...

您必须在相同的系统变量中定义maven和java home。

#3


0  

Try Rename M2_HOME at MAVEN_HOME Also change M2: %MAVEN_HOME%\bin

尝试在MAVEN_HOME重新命名M2_HOME,也可以更改M2: %MAVEN_HOME%\bin。

#4


0  

For me, the trick is to close and open another CMD window, to check if ir worked

对我来说,诀窍就是关闭并打开另一个CMD窗口,以检查ir是否有效。