12

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?

Vadim Kotov
  • 7,103
  • 8
  • 44
  • 57
azalut
  • 3,466
  • 7
  • 26
  • 40

2 Answers2

26

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.

Tunaki
  • 116,530
  • 39
  • 281
  • 370
  • 1
    +1. This answer is correct. I just downloaded the correct maven version, and the bin is there. Of course it is your responsibility to place those variables in your PATH, assuming you have some knowledge of how windows PATH works. – Joey Roosing Dec 01 '15 at 08:21
  • 1
    Hi, I have a similar issue. I have the correct maven installation and path variable. I developed the code in one pc (eclipse) when i move to home pc I get -Dmaven.multiModuleProjectDirectory system property is not set. Check $M2_HOME environment variable and mvn script match. error. Same version of eclipse and Maven are installed in both machines. What may be the problem? – Ferda-Ozdemir-Sonmez Nov 19 '16 at 12:14
  • @Ferda-Ozdemir-Sonmez If you're having this issue with Eclipse, it is probably that your m2e version is not uptodate. Make sure you use the latest version, see [the download page](https://www.eclipse.org/m2e/m2e-downloads.html). – Tunaki Nov 19 '16 at 12:20
  • Have a failing maven-invoker-plugin looking in the wrong place when M2_HOME and MAVEN_HOME are not set, still confusion around these env settings. – Greg Domjan Nov 02 '17 at 00:05
  • This was my problem as well ... I had downloaded the `source` and not the `binaries` ... :/ – Chris Allinson Dec 11 '19 at 23:04
0

If you want to keep your maven installation always up-to-date, it is easier to install it via Homebrew on Mac OS X or Linuxbrew on Linux.

mmizutani
  • 180
  • 1
  • 8