I\'ve tried installing Maven to Windows 7 with poor results. Some basic info:
Maven installation directory: C:\\Program Files\\Apache Software Foundation\\ap
If your downloaded package apache-maven-3.3.9 does not contain a bin folder your download is wrong. you have to download a zip file which contains bin, boot, conf, lib folder otherwise there has gone something wrong. The downloaded file should have about 4.8 mb size. You can check the file via md5 or SHA1 checksums.
In M2_HOME
- set C:\apache-maven-3.0.4
i.e. path without bin
.
In PATH
- set %M2_HOME%\bin
i.e. with bin
in path.
In my case the setup was correct:
Windows System Variables:
Windows User variables:
But I had the same problem when there was two installation of maven even though all references was pointing to the latest version which in my case was 3.3.9. After deleting the older version the same command recognised maven.
BEFORE:
maven -v
ERROR: M2_HOME is set to an invalid directory.
M2_HOME = "C:\dev\software\apache-maven-3.3.9"
Please set the M2_HOME variable in your environment to match the
location of the Maven installation
AFTER:
maven -v
Apache Maven 3.3.9
Maven home: C:\dev\software\apache-maven-3.3.9
Java version: 1.7.0_51, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk1.7.0_51\jre
You need to download the Maven file that has the name "Binary zip". For example: http://mirrors.digipower.vn/apache/maven/maven-3/3.1.1/binaries/apache-maven-3.1.1-bin.zip
All success after next steps.
On http://maven.apache.org/download.cgi page from 4 variants need download binary file.
Set environment variable (tip from @JamesB - https://stackoverflow.com/a/13093358/3941340):
JAVA_HOME=C:\Program Files\Java\jdk1.6.0_35
MAVEN_HOME=D:\software\apache-maven-3.0.4
PATH=%PATH%;%MAVEN_HOME%\bin;%JAVA_HOME%\bin
Check the System Variable M2_HOME and PATH in different maven locations.