Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install Maven in Windows?

Tags:

java

maven

apache

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)

like image 585
Nimit Bihari Avatar asked Jul 24 '16 07:07

Nimit Bihari


2 Answers

  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

like image 172
Do Nhu Vy Avatar answered Sep 21 '22 14:09

Do Nhu Vy


  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.

like image 43
Tiago Martins Peres Avatar answered Sep 19 '22 14:09

Tiago Martins Peres