Setup M2_HOME on your Apple MacBook

Here are the steps to download Maven on your apple MacBook and setup MAVEN_HOME

  1. Download the Maven binaries from https://maven.apache.org/download.cgi
  2. While downloading, select the apache-maven-3.8.6-bin.zip (Binary zip archive)
  3. Extract unzip apache-maven-3.8.6-bin.zip using the terminal (for this example I’ve downloaded and extracted it into Documents folder)
  4. On you user terminal path /Users/binarycipheruser (pwd to check your path on the terminal)
  5. Hit ls -al to see the list of files your user folder
  6. Open the file .zshenv using the command open ~/.zshenv (if the file is not available create one using touch .zshenv)
  7. Add the below lines to the file
  8. export M2_HOME=Documents/apache-maven-3.8.6/bin
  9. export PATH=$M2_HOME:$PATH
  10. Save the file and
  11. Close the terminal and reopen the terminal to check if we successfully set up the MAVEN_HOME
  12. Hit mvn –version  command
  13. You should see below message
Apache Maven 3.8.6 (84538c9988a25aec085021c365c560670ad80f63)
Maven home: /Users/binarycipheruser/Documents/apache-maven-3.8.6
Java version: 11.0.16, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/jdk-11.0.16.jdk/Contents/Home
Default locale: en_CA, platform encoding: UTF-8
OS name: "mac os x", version: "12.5.1", arch: "aarch64", family: "mac"

Here is the screenshot of the file

Note: If you are setting up on the bash command line use the file ~/.bashprofile

Ref: https://maven.apache.org/install.html

To setup JAVA_HOME Refere here

3 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

Enable Notifications OK No thanks