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:

  1. Download the Apache Maven zip file.
  2. Extract the zip file to a folder of your choice.
  3. Add Maven's \bin directory to the PATH of your OS.
  4. Optionally configure MAVEN_HOME and M2_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.

Maven environment variables.
M2_HOME and MAVEN_HOME are commonly configured Maven environment variables.

Validate the Maven install

After the Maven installation process is complete, open a new terminal window and query the system for the Maven version.

Maven version command.
Checking the version of the locally installed Maven instance is an easy way to validate the install.

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.

View All Videos