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¶
Installation via Homebrew (Recommended)¶
The easiest way to install Maven on a Mac is using Homebrew:
brew install maven
Manual Installation¶
- Download the Maven binary zip archive from the official website.
- Extract the archive to an appropriate location, such as
/opt/maven. - Add the
bindirectory to yourPATH. Open your~/.zshrc(or~/.bash_profile) and add:export PATH=/opt/maven/apache-maven-x.y.z/bin:$PATH - 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¶
- Download the Maven archive from the official website.
- Extract it to
/opt:sudo tar xf apache-maven-*.tar.gz -C /opt - Update your
PATHby editing~/.bashrc:export PATH=/opt/apache-maven-x.y.z/bin:$PATH - Run
source ~/.bashrcto apply the changes.
Windows¶
Installation¶
- Download the binary zip file from the official Apache Maven website.
- Extract the archive to a directory of your choice, for example,
C:\Program Files\Maven.
Configuring Environment Variables¶
- Open the Start Menu, search for "Environment Variables", and click Edit the system environment variables.
- Click the Environment Variables... button.
- Under System variables, locate the
Pathvariable, select it, and click Edit. - Click New and add the path to your Maven
bindirectory (e.g.,C:\Program Files\Maven\apache-maven-x.y.z\bin). - 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