Ann Tomy
Ann Tomy

Reputation: 1

I get the following error after downloading maven in my Mac. zsh: command not found: mvn

Here is the path variables echo $PATH /Downloads/apache-maven-3.8.4/bin:/Library/Java/JavaVirtualMachines/amazon-corretto-8.jdk/Contents/Home/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/amazon-corretto-8.jdk/Contents/Home

nano .zshrc
export JAVA_HOME=/Library/Java/JavaVirtualMachines/amazon-corretto-8.jdk/Contents/Home
export PATH=$JAVA_HOME/bin:$PATH

plugins=(git zsh-autosuggestions mvn)
export M2_HOME=/Downloads/apache-maven-3.8.4
export M2=$M2_HOME/bin
export PATH=$M2:$PATH

source .zshrc

Using macOs Big Sur

Upvotes: 0

Views: 1032

Answers (1)

Soubhik Mitra
Soubhik Mitra

Reputation: 1

Instead of the following,

export M2_HOME=/Downloads/apache-maven-3.8.4
export M2=$M2_HOME/bin
export PATH=$M2:$PATH

could you please try -

  • make sure you have moved maven to /Applications/
  • mv apache-maven-{your-version} /Applications/
export JAVA_HOME=$(/usr/libexec/java_home)
export M2_HOME=/Applications/apache-maven-3.9.6
export PATH=$PATH:$M2_HOME/bin

I was also searching for help, then this worked for me so thought of posting it as if that can be helpful!, Thanks!

I tried one more method(macOS Sonoma), this also seems to work :

1.chown -R root:wheel Downloads/apache-maven-3.9.6 
2.sudo mv Downloads/apache-maven-3.9.6 /opt/apache-maven
3.nano ~/.zshenv
export PATH=$PATH:/opt/apache-maven/bin
4.source ~/.zshenv
5.Restart your terminal

I hope that helps

Upvotes: 0

Related Questions