This article shows how to install Maven (3.6.3) on macOS Big Sur (version 11.1).
Related Articles
1. Homebrew install Maven on macOS
1.1 Install Homebrew, a package manager on macOS.
1.2 The command brew install maven
will install the latest Maven.
Terminal
% brew install maven
1.3 Done. The Maven is installed on macOS.
Terminal
% mvn -version
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: /usr/local/Cellar/maven/3.6.3_1/libexec
Java version: 15.0.1, vendor: N/A, runtime: /usr/local/Cellar/openjdk/15.0.1/libexec/openjdk.jdk/Contents/Home
Default locale: en_MY, platform encoding: UTF-8
OS name: "mac os x", version: "10.16", arch: "x86_64", family: "mac"
P.S At the time of writing, the latest Maven version is 3.6.3
1.4 Where does Homebrew installed the Maven?
The brew
will install the Maven packages at /usr/local/Cellar/maven/${version}
Terminal
% ls -lsa /usr/local/Cellar/maven/3.6.3_1
total 72
0 drwxr-xr-x 9 favtuts admin 288 Jan 11 11:10 .
0 drwxr-xr-x 3 favtuts admin 96 Jan 11 11:10 ..
0 drwxr-xr-x 3 favtuts admin 96 Jan 11 11:10 .brew
8 -rw-r--r-- 1 favtuts admin 756 Jan 11 11:10 INSTALL_RECEIPT.json
40 -rw-r--r-- 1 favtuts admin 17504 Nov 7 2019 LICENSE
16 -rw-r--r-- 1 favtuts admin 5141 Nov 7 2019 NOTICE
8 -rw-r--r-- 1 favtuts admin 2612 Nov 7 2019 README.txt
0 drwxr-xr-x 5 favtuts admin 160 Jan 11 11:10 bin
0 drwxr-xr-x 6 favtuts admin 192 Jan 11 11:10 libexec
The brew
also creates shortcut or symbolic links at /usr/local/opt/maven/
Terminal
% ls -lsa /usr/local/opt/ | grep maven
0 lrwxr-xr-x 1 favtuts admin 23 Jan 11 11:10 maven -> ../Cellar/maven/3.6.3_1
1.5 Where does Homebrew put the Maven configuration file, settings.xml
?
The settings.xml
is available at /usr/local/opt/maven/libexec/conf
Terminal
# real path
/usr/local/Cellar/maven/3.6.3_1/libexec/conf
# symbolic links to the above path
/usr/local/opt/maven/libexec/conf
Terminal
% ls -lsa /usr/local/opt/maven/libexec/conf
total 32
0 drwxr-xr-x 5 favtuts admin 160 Jan 14 07:02 .
0 drwxr-xr-x 6 favtuts admin 192 Jan 11 11:10 ..
0 drwxr-xr-x 3 favtuts admin 96 Nov 7 2019 logging
24 -rw-r--r-- 1 favtuts admin 10468 Nov 7 2019 settings.xml
8 -rw-r--r-- 1 favtuts admin 3747 Nov 7 2019 toolchains.xml
1.6 Where does Homebrew put the core mvn
executable file?
The mvn
is at /usr/local/bin/
Terminal
% ls -lsah /usr/local/bin/mvn
0 lrwxr-xr-x 1 favtus admin 31B Jan 11 11:10 /usr/local/bin/mvn -> ../Cellar/maven/3.6.3_1/bin/mvn
1.7 brew info maven
to show the detail of the Maven package.
Terminal
% brew info maven
maven: stable 3.6.3
Java-based project management
https://maven.apache.org/
Conflicts with:
mvnvm (because also installs a 'mvn' executable)
/usr/local/Cellar/maven/3.6.3_1 (87 files, 10.7MB) *
Built from source on 2021-01-11 at 11:10:48
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/maven.rb
License: Apache-2.0
==> Dependencies
Required: openjdk ✔
1.8 brew list maven
Terminal
% brew list maven
/usr/local/Cellar/maven/3.6.3_1/bin/mvn
/usr/local/Cellar/maven/3.6.3_1/bin/mvnDebug
/usr/local/Cellar/maven/3.6.3_1/bin/mvnyjp
/usr/local/Cellar/maven/3.6.3_1/libexec/bin/ (4 files)
/usr/local/Cellar/maven/3.6.3_1/libexec/boot/ (2 files)
/usr/local/Cellar/maven/3.6.3_1/libexec/conf/ (3 files)
/usr/local/Cellar/maven/3.6.3_1/libexec/lib/ (70 files)
1.9 Useful commands:
brew upgrade maven
to upgrade Maven.brew uninstall maven
to uninstall Maven.
2. Install Maven Manually
If Homebrew failed you or you don’t want the black-box magic, try to install the Maven manually.
2.1 Download the Maven, for example apache-maven-3.6.3-bin.tar.gz

2.2 The below command extracts the downloaded .tar.gz
file to the current user’s home directory ~
Terminal
% pwd
# In this example, the ${username} is favtuts
/Users/${username}/Downloads
% tar -xvzf apache-maven-3.6.3-bin.tar.gz -C ~
x apache-maven-3.6.3/README.txt
x apache-maven-3.6.3/LICENSE
x apache-maven-3.6.3/NOTICE
x apache-maven-3.6.3/lib/
#...
2.3 Now, the Maven folder is at this path /Users/favtuts/apache-maven-3.6.3
Terminal
% ls -lsa ~/apache-maven-3.6.3
total 64
0 drwxr-xr-x 9 favtuts staff 288 Jan 14 11:08 .
0 drwxr-xr-x+ 29 favtuts staff 928 Jan 14 11:08 ..
40 -rw-r--r-- 1 favtuts staff 17504 Nov 7 2019 LICENSE
16 -rw-r--r-- 1 favtuts staff 5141 Nov 7 2019 NOTICE
8 -rw-r--r-- 1 favtuts staff 2612 Nov 7 2019 README.txt
0 drwxr-xr-x 8 favtuts staff 256 Jan 14 11:08 bin
0 drwxr-xr-x 4 favtuts staff 128 Nov 7 2019 boot
0 drwxr-xr-x 5 favtuts staff 160 Nov 7 2019 conf
0 drwxr-xr-x 65 favtuts staff 2080 Nov 7 2019 lib
% cd ~/apache-maven-3.6.3
% pwd
/Users/favtuts/apache-maven-3.6.3
2.4 On macOS 10.5 Catalina or later, the default shell is zsh, and we can create the environment variables MAVEN_HOME
and update the PATH
in ~/.zshenv
.
Open the ~/.zshenv
and append the following content.
~/.zshenv
export MAVEN_HOME=~/apache-maven-3.6.3
export PATH=$PATH:$MAVEN_HOME/bin
Note
For macOS 10.14 Mojave and before, the default Terminal shell is bash
, and we can create the environment variables in ~/.bash_profile
.
Open the ~/.bash_profile
and append the following content.
~/.bash_profile
export MAVEN_HOME=~/apache-maven-3.6.3
export PATH=$PATH:$MAVEN_HOME/bin
P.S Read this Zsh Startup Files.
2.5 Source the ~/.zshenv
to reflect the changes.
Terminal
% source ~/.zshenv
2.6 Verification.
Terminal
% mvn -version
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: /Users/favtuts/apache-maven-3.6.3
Java version: 14, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/jdk-14.jdk/Contents/Home
Default locale: en_MY, platform encoding: UTF-8
OS name: "mac os x", version: "10.16", arch: "x86_64", family: "mac"
Done.