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?
After lot of failed tried attempts ,I found the solution
It was the ";" at end of JAVA_HOME which I always put at end of each new variable I set. So get rid of the ;.
JAVA_HOME set it in User Variable also (without the ";" ofcourse)
Sometimes in Windows whitespaces in paths are not recognized correctly
If you have a path problem and path seems like
c:\Program Files\....
try changing it in an old DOS format like
"C:\Progra~1\...
You can use
dir /x
to check correct syntax (third column)C:\>dir /x ... 11.01.2008 15:47 <DIR> DOCUME~1 Documents and Settings 01.12.2006 09:10 <DIR> MYPROJ~1 My Projects 21.01.2011 14:08 <DIR> PROGRA~1 Program Files ...
In my pc JAVA_HOME is (and it works)
"C:\Progra~1\Java\jdk1.8.0_121"
Tested in Windows 10
My situation was a bit different.
JAVA_HOME
was set properly to point to 1.7PATH
was set properly.Still my simple new Maven project was not working. What I noticed was the difference in the logs when I ran
mvn clean install
. For my older Maven projects, it showedBut for my new project it showed:
So, I looked at the
POM.xml
and noticed this thing in the old project's POM:Basically, this plugin tells which compiler version to use for compilation. Just added it to the new project's
POM.xml
and things worked.Hope it is useful to someone.
you should set JAVA_HOME or MAVEN_HOME without bin directory for example: - JAVA_HOME=C:\Program Files (x86)\Java\jdk1.7.0_45 - MAVEN_HOME=C:\Program Files (x86)\apache-maven-3.1.1 now path=.....;%MAVEN_HOME%\bin;%JAVA_HOME%\bin it's work correctly