In this tutorial, we are going to see how to install maven in Mac OSX.

Versions:

  • macOS Big Sur 11.04
  • Java 14
  • Maven

How to install Maven in Mac OSX:

Installing maven can be possible in Mac in two ways, one homebrew and direct package installation, let’s see brew installation here.

Maven install homebrew:

Make sure you have to install homebrew first, if you don’t have it yet, it’s straightforward.

Update/Upgrade Homebrew:

It’s always recommended to update homebrew before installing any package.

chandra~ % brew update
Updated 3 taps (homebrew/core, homebrew/cask and aws/tap).
==> New Formulae
[email protected]                       openliberty-microprofile4
openliberty-jakartaee8                   openliberty-webprofile8
==> Updated Formulae
...
..

The above brew update command gave me 10 outdated formulae and 2 casks. It may be different for you.

chandra ~ % brew upgrade
==> Casks with 'auto_updates' or 'version :latest' will not be upgraded; pass `-
==> Upgrading 2 outdated packages:
adoptopenjdk/openjdk/adoptopenjdk11 11.0.10,9 -> 11.0.11,9
adoptopenjdk/openjdk/adoptopenjdk8 8,282:b08 -> 8,292:b10
==> Upgrading adoptopenjdk11
==> Downloading https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/down
Already downloaded: /Users/chandra/Library/Caches/Homebrew/downloads/dab6f80b966fb15a315c5452b279d64fcb537cc3cbb6aeec812011d963b1c0da--OpenJDK11U-jdk_x64_mac_hotspot_11.0.11_9.pkg
=
....

So far, the prerequisites were done.

Install Maven:

Now let’s initiate our actual process with brew install maven

chandra~ % brew install maven
==> Downloading https://ghcr.io/v2/homebrew/core/openjdk/manifests/16.0.1
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/openjdk/blobs/sha256:55c120ab6b
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sh
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/maven/manifests/3.8.1
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/maven/blobs/sha256:f894602e16a4
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sh
######################################################################## 100.0%
==> Installing dependencies for maven: openjdk
==> Installing maven dependency: openjdk
==> Pouring openjdk--16.0.1.big_sur.bottle.tar.gz
🍺  /usr/local/Cellar/openjdk/16.0.1: 617 files, 330MB
==> Installing maven
==> Pouring maven--3.8.1.big_sur.bottle.tar.gz
🍺  /usr/local/Cellar/maven/3.8.1: 87 files, 10.8MB

Verify version:

mvn --versioncommand gives you the details about maven.

chandra ~ % mvn --version
Apache Maven 3.8.1 (05c21c65bdfed0f71a2f2ada8b84da59348c4c5d)
Maven home: /usr/local/Cellar/maven/3.8.1/libexec
Java version: 14.0.2, vendor: AdoptOpenJDK, runtime: /Library/Java/JavaVirtualMachines/adoptopenjdk-14.jdk/Contents/Home
Default locale: en_GB, platform encoding: UTF-8
OS name: "mac os x", version: "10.16", arch: "x86_64", family: "mac"

In the above output, you can find the maven version for me it is 3.8.1 and maven home path, where you can see all the maven libraries.

chandra % ls -a /usr/local/Cellar/maven/3.8.1/ 
.			INSTALL_RECEIPT.json	README.txt
..			LICENSE			bin
.brew			NOTICE			libexec

We can also find more info on maven packages using brew info maven command like the following.

chandra ~ % brew info maven
maven: stable 3.8.1 (bottled)
Java-based project management
https://maven.apache.org/
Conflicts with:
  mvnvm (because also installs a 'mvn' executable)
/usr/local/Cellar/maven/3.8.1 (87 files, 10.8MB) *
  Poured from bottle on 2021-07-21 at 13:07:53
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/maven.rb
License: Apache-2.0
==> Dependencies
Required: openjdk ✔
==> Analytics
install: 49,833 (30 days), 160,280 (90 days), 499,409 (365 days)
install-on-request: 49,533 (30 days), 159,293 (90 days), 494,769 (365 days)

References:

Happy Learning 🙂

About the Author:

Founder of onlinetutorialspoint.com Love Java, Python, Shell and opensource frameworks. Follow him on twitter and facebook for latest updates.

Leave A Comment