10

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)

Dr. Andrey Belkin
  • 795
  • 1
  • 9
  • 28
Nimit Bihari
  • 111
  • 1
  • 1
  • 6

6 Answers6

14
  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

Vy Do
  • 46,709
  • 59
  • 215
  • 313
  • Let's clean everything, then install everything from scratch. – Vy Do Jul 24 '16 at 08:17
  • 3
    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: http://maven.apache.org/download.cgi – khmarbaise Jul 24 '16 at 13:12
  • 2
    @DoNhuVy, I think there is type of ENV variable, it should be `%MAVEN_HOME%\bin` – Artavazd Balayan May 01 '18 at 11:45
9
  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.

Tiago Martins Peres
  • 14,289
  • 18
  • 86
  • 145
1

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

0

Follow the steps:

1. Download Maven from <https://maven.apache.org/>  
2. Unzip anywhere on your system
3. Go to Control pannel on your windows machine and edit the environmentalvariable(PATH = "your maven path/bin")  
4. Save   
5. Go to command prompt and run the command mvn -version
Pathik Vejani
  • 4,263
  • 8
  • 57
  • 98
Narendra
  • 1
  • 1
0

We can use M2_HOME property in environment variable - system property and configure the maven bin folder as value.

Karthick
  • 13
  • 4
  • 1
    Please provide additional details in your answer. As it's currently written, it's hard to understand your solution. – Community Aug 31 '21 at 10:46
  • This does not provide an answer to the question. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](https://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). – Vatsal Dholakiya Aug 31 '21 at 13:40
-1

https://www.mkyong.com/maven/how-to-install-maven-in-windows/ check this out..you need to have Java & you have to add maven details in environment variables path.

Sudha Velan
  • 633
  • 8
  • 24