Skip to content

Setting Up Maven

Apache Maven is a software project management and comprehension tool. Based on the concept of a Project Object Model (POM), Maven can manage a project's build, reporting and documentation from a central piece of information.

MacOS

The easiest way to install Maven on a Mac is using Homebrew:

brew install maven

Manual Installation

  1. Download the Maven binary zip archive from the official website.
  2. Extract the archive to an appropriate location, such as /opt/maven.
  3. Add the bin directory to your PATH. Open your ~/.zshrc (or ~/.bash_profile) and add:
    export PATH=/opt/maven/apache-maven-x.y.z/bin:$PATH
    
  4. Restart your terminal or run source ~/.zshrc.

Linux

Installation via Package Manager

On Ubuntu/Debian-based systems:

sudo apt update
sudo apt install maven

Manual Installation

  1. Download the Maven archive from the official website.
  2. Extract it to /opt:
    sudo tar xf apache-maven-*.tar.gz -C /opt
    
  3. Update your PATH by editing ~/.bashrc:
    export PATH=/opt/apache-maven-x.y.z/bin:$PATH
    
  4. Run source ~/.bashrc to apply the changes.

Windows

Installation

  1. Download the binary zip file from the official Apache Maven website.
  2. Extract the archive to a directory of your choice, for example, C:\Program Files\Maven.

Configuring Environment Variables

  1. Open the Start Menu, search for "Environment Variables", and click Edit the system environment variables.
  2. Click the Environment Variables... button.
  3. Under System variables, locate the Path variable, select it, and click Edit.
  4. Click New and add the path to your Maven bin directory (e.g., C:\Program Files\Maven\apache-maven-x.y.z\bin).
  5. Click OK to save and close all windows.

Verification (All Systems)

To verify that Maven has been installed correctly, open a new terminal or command prompt and run:

mvn -v
You should see the Maven version and related Java environment details printed to the console.