I was trying to install Maven Version apache-maven-3.3.9-bin on my Windows Machine.
As per the instruction given in the Readme File, I set the Path in Path Environment variable.
I made sure JAVA_HOME is set to the location of your JDK.
When I tried to run “mvn –version” to verify that it is correctly installed, I got error: M2_HOME is set to an invalid directory.
M2_HOME = “C:apache-maven-3.2.1”
Please set the M2_HOME variable in your environment to match the
location of the Maven installation
I realized that I already set the M2_Home and M2 variables in my earlier installation.
I just changed the path based on my new Maven installation directory and Bingo!
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T22:11:4
Maven home: C:apache-maven-3.3.9
Java version: 1.7.0_21, vendor: Oracle Corporation
Java home: C:Program FilesJavajdk1.7.0_21jre
Default locale: en_IN, platform encoding: Cp1252
OS name: “windows 7”, version: “6.1”, arch: “x86”, family: “windows”