I followed the Maven tutorial to the letter but I still can't get Maven installed on Windows.
When I run the following in command prompt:
E:\Documents and Settings\zach>mvn --version
I get:
'mvn' is not recognized as an internal or external command, operable program or batch file.
I navigated to the maven install folder and ran mvn --version
and got:
E:\java resources\apache-maven-2.2.0\bin>mvn --version
ERROR: JAVA_HOME is set to an invalid directory.
JAVA_HOME = "E:\Sun\SDK\jdk\bin"
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation
but when I run java -version
I get:
java version "1.6.0_14"
Java(TM) SE Runtime Environment (build 1.6.0_14-b08)
Java HotSpot(TM) Client VM (build 14.0-b16, mixed mode)
So I do have Java installed. Anyone know what the problem is?
Due to security restrictions at my current place of work I was unable to set enviroment variables on my Windows based PC.
My workaround was to copy the mvn.bat file from %M2% into C:\WINNT and add the following to the top of the batch file:
Not the nicest solution but it works. If anybody has any other way or work-around where the standard env vars are not able to be set into the system I'd welcome their response.
The JDK has switched locations of java.exe between 1.6 and 1.7!!!
In my case I found that the JAVA_HOME for the JDK had to add the \jre on the end. The mvn bat file is looking for java.exe and it looks for it in JAVA_HOME\bin. Its not there for JDK 1.7; it is in JAVA_HOME\jre\bin. In JDK 1.6 such it IS in JAVA_HOME\bin.
Hope this helps somebody.
Running eclipse and also running Maven will require you to store two path variables, one in your jdk1.7_x_x_x location and also in your jdk1.7_x_x_\bin. If you are using Windows, when you are in your environment variables, do the following:
1) create a USER variable called JAVA_HOME. Point this to the location of your JAVA file. For example: "C:\Program Files\Java\jdk1.7.0_51" (remove the quotes)
2) under the PATH, append %JAVA_HOME% to the PATH. This will add the file location from step 1 to your PATH. This is good for MAVEN
3) if you are using eclipse you need to have the path point to "C:\Program Files\Java\jdk1.7.0_51\bin". Now append %JAVA_HOME%\bin to the end of your path.
4) your path should look something like this: C:\Program Files (x86)\Google\google_appengine\;C:\Users\username\AppData\Roaming\npm;%M2%;%JAVA_HOME%;%JAVA_HOME%\bin
Notes: the items that are enclosed in %'s like %M2% are assigned variables. It looks redundant but necessary. You can confirm that everything works by typing in:
java -version
javac -version
mvn -version
Each of those three statements typed in comman prompt should not return errors.
I ran into this issue with a Grails install.
The problem was my JAVA_HOME was
c:\sun\jdk\
and my PATH has%JAVA_HOME%bin
I changed it to:
JAVA_HOME= "c:\sun\jdk" and PATH="%JAVA_HOME%\bin"
It worked after that.
using windows 10
I was facing issue .. then I removed JAVA_HOME variable completly and just added %JAVA_HOME%\bin in PATH then it worked!!! for mee
JAVA_HOME
should be set toE:\Sun\SDK\jdk
.PATH
should be set to include%JAVA_HOME%\bin
.