Skip to content

Installing Maven

rajivkanaujia edited this page Dec 20, 2020 · 1 revision

Install Maven via Homebrew

Run following command on Terminal

    $ brew update
    $ brew install maven

The response will be similar to

    Updating Homebrew...
    ==> Auto-updated Homebrew!
    Updated 1 tap (homebrew/core).
    ==> Updated Formulae
    nushell

    ==> Downloading https://www.apache.org/dyn/closer.lua?path=maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin
    ==> Downloading from https://downloads.apache.org/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz
    ######################################################################## 100.0%
    🍺  /usr/local/Cellar/maven/3.6.3_1: 87 files, 10.7MB, built in 7 seconds

Check location of mvn

    $ which mvn
    /usr/local/bin/mvn

Check the version using mvn

Note the location of "Maven home"

    $ mvn -v
    Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
    Maven home: /usr/local/Cellar/maven/3.6.3_1/libexec
    Java version: 14.0.1, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/jdk-14.0.1.jdk/Contents/Home
    Default locale: en_US, platform encoding: UTF-8
    OS name: "mac os x", version: "10.15.4", arch: "x86_64", family: "Mac"

Configure .bash_profile

export M2_HOME=/usr/local/Cellar/maven/3.6.3_1/libexec
export M2=${M2_HOME}/bin
export PATH=${PATH}:${M2_HOME}/bin
[ -d $M2_HOME ] && echo "    Directory $M2_HOME exists." || echo "    Error: Directory $M2_HOME does not exists."


Note: If you like the instructions here, please refer it on your posts/documentation. Contact me if there are corrections needed.