Install Maven on Windows
While the Java ecosystem is blessed with a number of powerful and capable build tools, Apache Maven remains the most popular. Its dependency management capabilities are second-to-none, and its simplicity makes it approachable to developers of all expertise levels.
How to install Apache Maven
It's not hard to get started with Apache Maven. Maven is packaged and distributed as a zip file, so installation of the tool simply involves the following steps:
- Download the Apache Maven zip file.
- Extract the zip file to a folder of your choice.
- Add Maven's
\bin
directory to thePATH
of your OS. - Optionally configure
MAVEN_HOME
andM2_HOME
.
Maven environment variables
Historically, applications looking for the root installation directory of Maven would search the OS for an environment variable named M2_HOME
or MAVEN_HOME
. This practice has become less common in recent years, so configuration of these variables is rarely required and can be considered optional.
If you do configure these variables, know that they point to the installation directory and not to the \bin
directory as with the PATH
.
Validate the Maven install
After the Maven installation process is complete, open a new terminal window and query the system for the Maven version.
If the mvn --version
command returns information about the Maven install and the version of Java being used, you know you have installed Maven successfully.
Cameron McKenzie has been a Java EE software engineer for 20 years. His current specialties include Agile development; DevOps; Spring; and container-based technologies such as Docker, Swarm and Kubernetes.