How to install Maven in Windows?
Solution 1
Download Maven at here.
Unzip, for example:
C:\tools\
Press Windows+R, type
systempropertiesadvanced
, press EnterSet environment:
MAVEN_HOME
=C:\tools
Add to PATH
environment variable: ;%MAVEN_HOME%\bin
Close all
-
Call
cmd
, run command:mvn -v
Solution 2
- Open PowerShell or terminal and run
java -version
to make sure Java is installed
- 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
- Place the downloaded file in the folder where you have all your Java related things (in my case,
C:\Program Files\Java
)
- Right click in that file and "Extract here". Then, delete the .zip file.
if we open that new folder we should have something like
- Go to advanced system settings (by searching for that term or right clicking in "This PC" > Properties) and "Environment variables".
- Define a new System Environment Variable by clicking New and
Variable Name: M2_HOME
VARIABLE VALUE: C:\Program Files\Java\apache-maven-3.6.3
- Append the bin subdirectory of the folder
C:\Program Files\Java\apache-maven-3.6.3
into the PATH variable
- Restart your computer and then run
mvn --version
.
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.
Nimit Bihari
Updated on June 26, 2022Comments
-
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 almost 8 yearsLet's clean everything, then install everything from scratch.
-
khmarbaise almost 8 yearsRemove
MAVEN_HOME
really not needed only the bin folder into PATH that's it. And of course JAVA_HOME setting to JDK...and thanmvn --version
...BTW: Use for download this: maven.apache.org/download.cgi -
Sudha Velan over 7 yearsopen cmd prompt and type "mvn -version".You will get maven details.If you get that then maven home is set.
-
Artavazd Balayan about 6 years@DoNhuVy, I think there is type of ENV variable, it should be
%MAVEN_HOME%\bin
-
alelom about 3 yearsCan 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 about 3 years@alexlomba87 you can do that too yes!
-
Admin over 2 yearsPlease provide additional details in your answer. As it's currently written, it's hard to understand your solution.
-
Vatsal Dholakiya over 2 yearsThis 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 over 2 yearsWorked for me on Windows 11 as well.