8

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
  • 686
  • 1
  • 6
  • 21
Nimit Bihari
  • 91
  • 1
  • 1
  • 4

5 Answers5

13
  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

Do Nhu Vy
  • 33,131
  • 37
  • 143
  • 202
  • Let's clean everything, then install everything from scratch. – Do Nhu Vy 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
4
  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.

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,048
  • 6
  • 47
  • 84
Narendra
  • 1
  • 1
-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
  • 622
  • 8
  • 22