How to Uninstall Maven in Mac

Profile picture for user devraj

Use below steps to uninstall Maven on Mac OS. Below command is tested on following version of Mac OS:

  1. Mac OS Monterey version 12.3
  2. Mac OS Mojave version 10.14

Table of Contents

  1. Manually Uninstall
  2. Uninstall using brew
  3. Upgrade using brew
  4. Video tutorial

Steps to Uninstall Maven on Mac OS

Step 1: Locate Maven

$ which mvn

This will output /usr/local/bin/mvn.

Step 2: Navigate to bin directory

$ cd /usr/local/bin

Step 3: Search where maven is installed

$ ls -lrt | grep -i mvn
  • ls -lrt: will give a long listing, oldest first, which is handy for seeing which files in a large directory have recently been changed.
  • grep: The grep filter searches a file for a particular pattern of characters, and displays all lines that contain that pattern.
  • -i: ignores, case for matching  

It will output

lrwxr-xr-x  1 user  admin. 31 Mar  1 00:00 mvn -> ../Cellar/maven/3.6.3_1/bin/mvn
lrwxr-xr-x  1 user  admin. 36 Mar  1 00:00 mvnDebug -> ../Cellar/maven/3.6.3_1/bin/mvnDebug
lrwxr-xr-x  1 user  admin. 34 Mar  1 00:00 mvnyjp -> ../Cellar/maven/3.6.3_1/bin/mvnyjp

Here, you can see there is maven directory inside Cellar

Step 4: Navigate to Cellar Directory

$ cd ../Cellar/

Step 5: Remove Maven Directory

$ rm -rf maven

-rf allows to delete non-empty directories forcefully.

brew Uninstall Maven

$ brew uninstall maven

brew Upgrade Maven

$ brew upgrade maven

Video Tutorial: Uninstall Maven Mac