Error: JAVA_HOME is set to invalid directory

I am trying to run maven install but I always get this error

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

I know the error says everything, but I've tried everything here. I have the following setup:

System variables:

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

M2: % M2_HOME% \ bin

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

I added all the way, maybe someone is interested in it. please take a look at the last part.


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;


Side of your interest:



I tried this by uninstalling %JAVA_HOME%\bin;

too, but it doesn't work as I have this path using SDK install at the beginning of the pathC:\Program Files\Java\jdk1.7.0_51\bin

I tried to add a parameter to custom variables and it doesn't work.


source to share

4 answers

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

Maven says JAVA_HOME

there is a semicolon after the directory name in the variable name. Remove the semicolon.



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



Try renaming M2_HOME to MAVEN_HOME Also change M2 :% MAVEN_HOME% \ bin



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



All Articles