Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing Maven 3.3.9, how to set M2_HOME, MAVEN_HOME and bin folder?

I am trying to install Maven 3.3.9 on my new laptop but it seems to be incredibly difficult. I am not sure what changed since versions 3.0 which I have been mostly using but now I cant set M2_HOME, MAVEN_HOME and PATH variables properly.

Maven home page tells me to set it like this:

  • MAVEN_HOME: C:/apache-maven-3.3.9
  • M2_HOME: C:/apache-maven-3.3.9
  • PATH: C:/apache-maven-3.3.9/bin

but that, as you may guess, doesn't work. Whats more, there is even no bin folder inside apache-maven-3.3.9! I have found directory: C:/apache-maven-3.3.9/apache-maven/src/bin but it doesn't help as well.

How to set it properly?

like image 247
azalut Avatar asked Dec 01 '15 08:12

azalut


People also ask

What should M2_HOME point to?

The M2_HOME is equivalent to JAVA_HOME and should point to the installation directory of Maven.

Which environment variable should be set to Maven installation?

Set the JAVA_HOME environment variable to point to the base directory location where Java is installed on your machine.

How do I set system variables in Maven?

Click on the Environment Variables there. Click on New in the new pop-up window in the System variables. Enter MAVEN_HOME (all characters in capital case) in the Variable name field. Paste the copied earlier path to the Maven folder in the Variable value.

Do we need to set PATH for Maven?

The path of maven should be %maven home%/bin. For example, E:\apache-maven-3.1. 1\bin .


1 Answers

It seems you downloaded the wrong distributed archive from the Maven website: you downloaded the source and not the binary.

Going to the download page, you need to choose the "Binary zip archive" (or "Binary tar.gz archive"). After that, you can follow the installation steps from the install page but the steps are really straight-forward:

  • Ensure JAVA_HOME environment variable is set and points to your JDK installation
  • Extract distribution archive in any directory
  • Add the bin directory of the created directory apache-maven-3.3.9 to the PATH environment variable

There is no need to set the M2_HOME or MAVEN_HOME environment variable.

like image 166
Tunaki Avatar answered Sep 20 '22 12:09

Tunaki