Install Maven on Windows: In our previous post of the Maven tutorial series, we are learning the basics of Maven and the Life Cycle of Maven. But in this post, we are going to learn a little bit more and also try to do hands-on Maven things.
Before Maven, the process of building and managing a Java-based project was complicated and time-consuming. Maven is a powerful project management tool that uses the Project Object Model (POM) to help you download dependencies automatically. With Maven, you can easily manage your Java-based projects with less effort and time investment.
Post On: | Install Maven |
Post Type: | Maven Tutorial |
Published On: | www.softwaretestingo.com |
Applicable For: | Freshers & Experience |
Get Updates: | Join Our Telegram Group |
How to Install Maven on Windows?
Maven is the perfect tool for building Java applications. It’s written in Java, so it’s perfect for programs that run on the JVM. Just make sure you have Java installed first, then you can install and use Maven without any problems.
Prerequisites to Install Maven
Before going with the learning process let’s try to find out what is the minimum system requirement to deal with Maven. You can get all the system requirement details below:
- A system running Windows.
- A working Internet connection.
- Access to an account with administrator privileges.
- Access to the command prompt.
We have already published a blog post regarding how to install java on windows. You can check that by clicking on the link.
In order to install Maven on your Windows machine, you will first need to have the Java Development Kit (JDK) installed. The latest version of Maven requires JDK 1.7 or above in order to run properly.
Why JDK is Required?
As you know Maven is a Java-based tool, so to execute the commands of Maven we have to install Java in our local system first. When we are mentioning Java, that means we are talking about JDK (Java Development Kit), not about JRE (Java Runtime Environment). If you have any questions what’s the difference between JDK & JRE? then you can read one of our previous posts where we mentioned that in detail.
Install JDK For Windows
Installing Oracle JDK is a paid process, but we can save money by using OpenJDK instead. It’s free to use and there’s no need to worry about licenses or support from Oracle.
You can check this tutorial where we have already shared a detailed blog post on OpenJDK windows installation steps.
After successfully installed and configured you can validate that by running the below command:
C:\>java -version
Install Maven on Windows
After configuring the Java on your windows machine now we need to install Maven on our machine. To Install Maven on your machine follow the below steps.
There are different versions of Apache maven available on the official website. But before using those you have to remember that different apache maven version requires a minimum JDK version to be installed on that machine.
1. Maven 3.3+ requires JDK 1.7+
2. Maven 3.2 requires JDK 1.6+
3. Maven 3.0/3.1 requires JDK 1.5+
Maven Download
1 . Visit the Maven download page to find the version of Maven you want to install. The Files section contains all the latest versions, while Previous Releases give access to older ones.
2 . Click on the respective link which you want to download the binary zip archive of Maven 3.8.6, which is the latest version at the time of writing this tutorial! For this tutorial, we have downloaded the
Binary zip archive.
3 . Once you’ve got the Maven archive downloaded, go ahead and extract it to a directory of your choice. No installation process is required! For this tutorial, we have extracted the files into: C:\Users\XX\Downloads\DL_Files\apache-maven-3.8.6
Setting up Maven Environment Variables
After Maven Download, the next thing is we have to configure the system variable. So follow the below steps to configure the M2_HOME, MAVEN_HOME, and Path.
- Click on the Search bar and Try to Find out the environment variables.
- Click on the Edit the system environment variables result.
After clicking on Edit the system environment variables, you will get a window System properties.
Click on the Environment Variables, After that you will get another environment variables window. Click the New button under the System variables section to add a new system environment variable.
In order to set up Maven, you’ll need to add its home directory to your system variables. To do this, simply enter MAVEN_HOME as the variable name and the path to the Maven folder as the variable value. This will help ensure things run smoothly and click OK to save the new system variable.
The next thing is to click on the “Path” variable under the “System variables” section in the Environment Variables window. Clicking on the “Edit” button will allow you to edit the variable.
Click the New button in the Edit environment variable window. Enter %MAVEN_HOME%\bin into the new field. Click OK to save changes to your Path variable.
Note: If you see the error ‘mvn’ is not recognized as an internal or external command, operable program, or batch file, it may be because you have not added the path to the Maven home directory to your Path variable.
Again Click the “OK” button in the “Environment Variables” window to save your changes.
Maven Verify Command
Great job! Your Maven installation is complete. Now let’s test it out from the Windows Command Prompt. To do this, go to the run (Windows+R) and type ‘cmd’ in the box. At the prompt, type: mvn -version
If the above command gives you the maven version, it means that your environment variable is set correctly and the Maven installation is successful.
Conclusion:
We have discussed in detail how to install Maven on your windows machine. But after following this still, if you have any concerns then you can ask in the comment section.
Leave a Reply