How to Install Apache Maven
Installing Apache Maven is pretty easy. We’re going to show you how to do this on Linux, Windows, and Mac OSX.
How to Install Apache Maven on Linux
On a debian base system like Ubuntu or Mint you can use this:
sudo apt update
sudo apt install maven
On Arch Linux, Manjaro, or another derivative you can use the following:
pacman -S maven
To install on Red Hat ( RHEL, Fedora, Centos, Rocy ) use one of the following depending on new your system is:
yum install maven2
dnf install maven -y
Manual installation on Linux
Make sure to swap the version numbers in these instructions for the version that you are using.
Download it from HERE
Unpack it:
sudo tar -xvf apache-maven-3.3.9-bin.tar.gz -C /opt/maven
Add environment variables to your profile:
vi .bashrcexport M2_HOME=/opt/maven export M2=$M2_HOME/bin export PATH=$M2:$PATH
Reload environment variables:
source .bashrc
Test it:
mvn -version
How to Install Apache Maven on OSX
Download it from HERE
Unpack it:
tar xvfz Downloads/apache-maven*bin.tar.gz
Fix permissions / ownership:
chown -R root:wheel Downloads/apache-maven*
Move it to the opt directory:
mv Downloads/apache-maven* /opt/apache-maven
Add it to your path:
vi ~/.zshenvexport PATH=$PATH:/opt/apache-maven/bin
Source your environment so that the changes to your path will become effective:
source ~/.zshenv
Test it:
mvn -version
How to Install Apache Maven on Windows
There is more than one way to install Maven on Windows.
The Easy Way
If you have Chocolatey installed you can just use that to quickly install maven like this:
choco install maven
Manually Install Maven
Download the Windows zip file from HERE
Using system properties set these variables:
M2_HOME |
MAVEN_HOME |
and update this variable:
PATH |