How to Install Apache Maven on Windows
Introduction
Apache Maven is a software project management and comprehension tool. This is developing under Apache Foundation. This tutorial will help you to install Apache Maven on Windows system.
Requirements
Apache Maven required Java Development Kit (JDK) to be installed on the system. Apache Maven 3.3 requires JDK 1.7 or above to execute. So make sure your server fulfill requirements before installing Apache maven.
- Maven 3.3.X => JAVA 7 or later
- Maven 3.2.X => JAVA 6 or later
- Maven 3.1.X => JAVA 5 or later
Download Apache Maven
To download the latest version of Apache Maven, Visit its official website download page. At the writing time of this tutorial, Apache Maven 3.3.9 is the latest version available.
For this tutorial, I have downloaded apache-maven-3.3.9-bin.zip and extract its content under c:\Apache\Maven
Configure JAVA_HOME
Make sure you have set JAVA_HOME environment variable. If not already set, add this under system environment variables. To open system properties type sysdm.cpl from run window.
Configure Maven Environment
Apache Maven required MAVEN_HOME and M2_HOME environment variable to set. You also need to add Apache maven bin location under systems PATH environment variable.
Also appened ;c:\Apache\Maven\bin under Path environment variable.
Verify Installation
Finally, You have successfully installed Apache Maven on your Windows system. Now open a command prompt and run mvn –version command to verify installation and installed version.
How to install Maven on Windows, Linux, Mac
Last modified: April 2, 2020
1. Overview
Simply put, Maven is a command-line tool for building Java applications.
The Maven project provides a simple ZIP file containing a precompiled version of Maven for your convenience. There is no installer. It’s up to you to set up your prerequisites and environment to run Maven.
The installation of Apache Maven is a simple process of extracting the archive and adding the bin folder with the mvn command to the PATH.
1.1. Prerequisites
Maven is written in Java (and primarily used for building JVM programs). Thus, the major prerequisite is the Java JDK. You need to install the Java JDK (e.g. from Oracle’s download site), and you should install it to a pathname without spaces.
Once Java is installed, you must ensure that the commands from the Java JDK are in your PATH environment variable. Running, for example:
must display the right version number.
Further reading:
Apache Maven Tutorial
Maven Dependency Scopes
How to Create an Executable JAR with Maven
2. Installing Maven on Windows
To install Maven on windows, head over to Apache Maven site to download the latest version, select the Maven zip file, for example apache-maven-3.3.9-bin.zip.
Unzip it to the folder you want Maven to live.
2.1. Adding Maven to the Environment Path
Add both M2_HOME and MAVEN_HOME variables to the Windows environment using system properties, and point it to your Maven folder.
Update the PATH variable by appending the Maven bin folder – %M2_HOME%\bin, so that you can run the Maven’s command everywhere.
in the command prompt. It should display the Maven version, the java version, and the operating system information. That’s it, you have set up Maven on your Windows system.
3. Installing Maven on Linux
To install Maven on the Linux operating system, download the latest version from the Apache Maven site, select the Maven binary tar.gz file, for example: apache-maven-3.3.9-bin.tar.gz.
Extract the archive to your desired location.
3.1. Adding Maven to the Environment Path
Open the command terminal and run the following commands to set the environment variables:
with M2_Home path corresponding with the location of your extracted Maven files.
Now append the M2 variable to the system path:
Finally, verify if Maven has been added by running:
The output should be as follows:
You have successfully installed Maven on your Linux system.
3.2. Installing Maven on Ubuntu
In a terminal, run apt-cache search maven, to get all the available Maven packages:
The Maven package always comes with latest Apache Maven.
Run command sudo apt-get install maven, to install the latest Apache Maven.
This will take a few minutes to download. Once downloaded you can verify by running the mvn -version to verify your installation.
4. Installing Maven on Mac OS X
To install Maven on Mac OS X operating system, download the latest version from the Apache Maven site, select the Maven binary tar.gz file, for example: apache-maven-3.3.9-bin.tar.gz.
Extract the archive to your desired location.
4.1. Adding Maven to the Environment Path
Open the terminal and switch to the directory where the files were extracted to and then login as Super – User.
Remove the tar.gz archive:
Fix the permissions:
Switch the Maven contents:
Archive the Admin session:
Add Maven binaries to the path and append.
Ctrl+x to Save and Exit from “nano”.
To load the new set up run:
To test the new installation run:
You are now ready to use Maven on your Mac OS X.
4.2. HighSierra Compatibility
For HighSierra users, we’ll need to additionally add Maven binaries to the path and append.
Ctrl+x to save and exit from “nano”.
To load the new set up run: bash
5. Conclusion
This quick guide illustrated how to install Maven on the major operating systems for development.
To learn how to get started with Spring with Maven – check out the tutorial here.
How to install maven on windows
Maven is a build and dependency management tool for Java based application development. Just like other Java based development tools, it is not installed as Windows service, rather it is configured using windows environment variables.
In this maven tutorial, I am installing maven on a Windows 7 32bit machine.
Windows environment variables location:
Control Panel > All Control Panel Items > System > Advanced system settings > Environment Variables
Follow the steps needed to install maven on windows operating system.
Step 1) Install JDK and Add ‘JAVA_HOME’ Environment Variable
To install java, download JDK installer and add/update the JAVA_HOME variable to JDK install folder.
Step 2) Download Maven and add ‘MAVEN_HOME’ and ‘M2_HOME’ Environment Variables
Maven can be downloaded from this location. I have extracted it in location – D:/Latest Setup/apache-maven-3.0.4 . You can choose your own location.
Set the M2_HOME and MAVEN_HOME variable to maven installation folder.
Step 3) Include ‘maven/bin’ directory in ‘PATH’ variable
To run maven from command prompt, this is necessary. Update the PATH variable with ‘Maven-installation/bin’ directory .
Step 4) Verify maven in console
Maven installation is complete. Now lets test it from windows command prompt.
- Go to start menu and type cmd in application location search box.
- Press ENTER . A new command prompt will be opened.
- Type mvn -version in command prompt and hit ENTER .
This should show the version information of maven installed. If there is any error shown, cross-check all above steps.
In this tutorial, we learned how to install maven on windows.