How to install maven

Maven is a build automation tool used primarily for Java projects. Maven addresses two aspects of building software: first, it describes how software is built, and second, it describes its dependencies. Maven is very useful in one particular scenario. Suppose you are a team of ten developers working on a same project and that project is having lots of jar files like spring boot, junit and many more, every time you make changes and add jar file to the project, you will have to let everyone know about the new jar file and provide them the jar file, its possible that you may miss a jar and the project will not run properly. With maven you can mention all the jars(dependencies) being used in your project in a single file called pom.xml file and this file will the part of your project, everyone can see, change this file and automatically maven will download all the dependencies mentioned in this file.

In this post we will learn how to install maven. Maven is not an executable, you just have to download it from this site : Apache Maven

1. Once you download the .zip file, extract it in your preferred location, I stored it like below :

 

2. Make sure JDK is installed and JAVA_PATH is set as below :

Go to Control Panel > System and Security > System > Advanced System Settings.
Click on Environment Variables. Please look at the snap below :

3. After you click on Environment variables, in a section System Variable click on New button. It will popup window like below. in ‘Edit System Variable’ window, fill the Variable name as shown in the snapshot below and Variable value will be the path of your jdk, please note you cant copy the path like below, you have to look for jdk on your system and paste that path in Variable value.

4. Create one more variable like we did in step 3. Name it MAVEN_HOME and variable value will be the path of your maven folder you downloaded.

5. Now you need to edit Path variable, which is already present in System Variables. Double click on Path Variable > Click New and add %MAVEN_HOME%\bin inside the new text box like below.

6. Verify that maven is working.
Yes you dont have to restart or refresh, nothing, just open Command Prompt and run a command

mvn -version

You should see result like this.

Congratulations your maven installation is completed, let me know in the comments below if you face any problem during the process.