Installing Apache Maven on Windows & Mac

Installing Apache Maven on Windows and Mac: To use Maven for our project, we first need to install it on our computer. In this post, we’ll show you how to set up Maven on both Windows and Mac.

When we don’t use Maven, then building and managing a Java project is hard and takes a lot of time. Maven is a tool that helps manage Java projects easily. It uses something called the Project Object Model (POM) to download the things your project needs automatically.

Post On:Install Maven
Post Type:Maven Tutorial
Published On:www.softwaretestingo.com
Applicable For:Freshers & Experience

How to Install Maven on Windows?

Maven is great for building Java applications. It’s made in Java, so it works perfectly with programs that run on the Java Virtual Machine (JVM). But first, you need to have Java installed on your computer.

Prerequisites to Install Maven

Things You Need Before Installing Maven:

A computer running Windows.
An internet connection.
Administrator access on your computer.
Access to the command prompt.

We have a blog post on how to install Java on Windows, which you can check out. To install Maven, you need to have the Java Development Kit (JDK) installed.

Installing Apache Maven on Windows & Mac 1

Why Do You Need JDK?

Maven is a tool made with Java, so you need Java to use it. Specifically, you need the Java Development Kit (JDK), not just the Java Runtime Environment (JRE). If you’re not sure about the difference, we have another post that explains it.

Install JDK For Windows

Oracle JDK costs money, but you can use OpenJDK for free. It works the same way, and you don’t need to worry about licenses.

After you install Java, you can check if it’s installed correctly by typing the Java -version in the command prompt. 

Javac Result
Javac Result

Maven Setup For Windows

After configuring the Java on your Windows machine, you now need to install Maven on our machine. To install Maven on your machine, follow the steps below.

Different versions of Apache Maven are 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.

Maven 3.3+ requires JDK 1.7+
Maven 3.2 requires JDK 1.6+
Maven 3.0/3.1 requires JDK 1.5+

Maven Download

1. Go to the Maven download page and find the version you want to install. The latest versions are in the Files section, and older ones are in Previous Releases.

2. Click on the link to download the binary zip archive for the version you want. For example, you might download Maven 3.8.6.

Maven File Section
Maven File Section

3. After downloading, extract the zip file to a folder. There’s no need for a complicated installation process. For example, you might extract it to any location: C:\Users\XX\Downloads\DL_Files\apache-maven-3.8.6.

Maven Files Stored Location
Maven Files Stored Location

Setting up Maven Environment Variables

After downloading Maven, you need to set up some environment variables. So follow the below steps to configure the M2_HOME, MAVEN_HOME Path.

  • Search for “environment variables” in the Windows search bar.
  • Click on “Edit the system environment variables.”
Maven Environment Variables
Maven Environment Variables

After clicking on Edit the system environment variables, you will get a window System properties.

Advance System Settings
Advance System Settings

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.

Maven System Variable
Maven System 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. Click OK to save the new system variable.

Maven New System Variable
Maven New System Variable

The next thing to do is 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.

Maven Path System Variable
Maven Path System 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.

Maven Path System Variable Added To Path Variable
Maven Path System Variable Added To Path Variable
Installing Apache Maven on Windows & Mac 1

Again, Click the “OK” button in the “Environment Variables” window to save your changes.

Maven Verify Command

To check if Maven is installed correctly, open the command prompt and type: mvn -version. If you see the Maven version, your installation is successful.

If the above command gives you the Maven version, it means that your environment variable is set correctly and the Maven installation is successful.

Maven Version Validate
Maven Version Validate

Conclusion:

Now you know how to install Maven on your Windows computer! Maven is a great tool that makes managing Java projects easier. Just follow the steps to set it up, and you’ll be ready to use it in no time. If you found this guide helpful, please share it with others who might need it. Let’s help everyone get started with Maven!

Avatar for Softwaretestingo Editorial Board

I love open-source technologies and am very passionate about software development. I like to share my knowledge with others, especially on technology that's why I have given all the examples as simple as possible to understand for beginners. All the code posted on my blog is developed, compiled, and tested in my development environment. If you find any mistakes or bugs, Please drop an email to softwaretestingo.com@gmail.com, or You can join me on Linkedin.

Leave a Comment