Error: JAVA_HOME is set to an invalid directory
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.
MrPencil
Updated on June 07, 2022Comments
-
MrPencil almost 2 years
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 pathC:\Program Files\Java\jdk1.7.0_51\bin
I have tried to add the setting to the user variables and it does not work.
-
Admin almost 9 yearswhat is M2 and M2_HOME ?
-
Dragondraikk almost 9 years@Kushal those are Maven's Envars
-
Adarsh almost 5 yearstry this : stackoverflow.com/a/45182761/2849146
-
-
MrPencil almost 9 yearsThere is no semi-colon but I had it before. I had just to restart my cmd it works now. `
-
W vd L almost 9 yearsaye, if you change a system variable, always restart cmd :-)
-
Jesper almost 9 years@MrPencil Yes, because the command prompt unfortunately doesn't pick up changes to the environment variables immediately - you have to re-open the command prompt.
-
forgivenson almost 9 yearsOr (at least if you are using bash), you can run the
source
command on your.bashrc
file to reload the environment variables in that file.