Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: JAVA_HOME is set to an invalid directory

I am trying to get maven installation to work but I am always getting 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;"
Please set the JAVA_HOME variable in your environment to match the location of your Java installation.

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: %M2_HOME%\bin

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

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

like image 769
MrPencil Avatar asked Mar 22 '26 09:03

MrPencil


1 Answers

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.

like image 130
Jesper Avatar answered Mar 24 '26 00:03

Jesper



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!