How to install Maven in Windows?

14,581

Solution 1

  1. Download Maven at here.

  2. Unzip, for example: C:\tools\

  3. Press Windows+R, type systempropertiesadvanced, press Enter

  4. Set environment: MAVEN_HOME = C:\tools

Add to PATH environment variable: ;%MAVEN_HOME%\bin

  1. Close all

  2. Call cmd, run command:

    mvn -v

Solution 2

  1. Open PowerShell or terminal and run java -version to make sure Java is installed

Java is installed

  1. Go to Apache Maven's download page and, if you're using Maven just as a tool, download the "Binary zip archive" from the link

Apache Maven download page

  1. Place the downloaded file in the folder where you have all your Java related things (in my case, C:\Program Files\Java)

Java folder

  1. Right click in that file and "Extract here". Then, delete the .zip file.

Extract Maven binary zip

if we open that new folder we should have something like

Maven Windows folder

  1. Go to advanced system settings (by searching for that term or right clicking in "This PC" > Properties) and "Environment variables".

View advanced properties

  1. Define a new System Environment Variable by clicking New and

M2_HOME Environment Variable

Variable Name: M2_HOME

VARIABLE VALUE: C:\Program Files\Java\apache-maven-3.6.3
  1. Append the bin subdirectory of the folder C:\Program Files\Java\apache-maven-3.6.3 into the PATH variable

Add Maven to Path

  1. Restart your computer and then run mvn --version.

Maven installed in Windows 10

That's it, you have now Maven installed in Windows 10.

Solution 3

Add system variable JAVA_HOME (with address JDK) and M2_HOME with route directory maven.

Share:
14,581
Nimit Bihari
Author by

Nimit Bihari

Updated on June 26, 2022

Comments

  • Nimit Bihari
    Nimit Bihari almost 2 years

    Hello I am just download maven binaries and after set all the environment variable, I am running mvn -version cmd and get this exception.

    Exception in thread "main" java.lang.IllegalAccessError: tried to access field org.codehaus.plexus.util.Os.OS_NAME from class org.apache.maven.cli.CLIReportingUtils at org.apache.maven.cli.CLIReportingUtils.showVersion(CLIReportingUtils.java:71) at org.apache.maven.cli.MavenCli.cli(MavenCli.java:423) at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:277) at org.apache.maven.cli.MavenCli.main(MavenCli.java:199) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289) at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415) at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)

  • James Grey
    James Grey almost 8 years
    Let's clean everything, then install everything from scratch.
  • khmarbaise
    khmarbaise almost 8 years
    Remove MAVEN_HOME really not needed only the bin folder into PATH that's it. And of course JAVA_HOME setting to JDK...and than mvn --version...BTW: Use for download this: maven.apache.org/download.cgi
  • Sudha Velan
    Sudha Velan over 7 years
    open cmd prompt and type "mvn -version".You will get maven details.If you get that then maven home is set.
  • Artavazd Balayan
    Artavazd Balayan about 6 years
    @DoNhuVy, I think there is type of ENV variable, it should be %MAVEN_HOME%\bin
  • alelom
    alelom about 3 years
    Can you clarify point 7? What do you mean append? Why not creating directly the variable with the correct path in point 6?
  • Tiago Martins Peres
    Tiago Martins Peres about 3 years
    @alexlomba87 you can do that too yes!
  • Admin
    Admin over 2 years
    Please provide additional details in your answer. As it's currently written, it's hard to understand your solution.
  • Vatsal Dholakiya
    Vatsal Dholakiya over 2 years
    This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker.
  • Jash Shah
    Jash Shah over 2 years
    Worked for me on Windows 11 as well.