Home  >  Q&A  >  body text

java - macbook failed to install maven, -bash: mvn: command not found

When installing maven, it reported -bash: mvn: command not found. I checked multiple environment variables and it was correct. Now I don’t know how to solve the problem

習慣沉默習慣沉默2673 days ago817

reply all(4)I'll reply

  • 滿天的星座

    滿天的星座2017-05-27 17:43:45

    /$M2_HOME/bin错了,应该是$M2_HOME/bin

    reply
    0
  • 黄舟

    黄舟2017-05-27 17:43:45

    1. source .bash_profile

    2. Reopen a window

    reply
    0
  • 过去多啦不再A梦

    过去多啦不再A梦2017-05-27 17:43:45

    This is my configuration as follows, you can change the path to yours

    export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_73.jdk/Contents/Home
    export PATH=$PATH:$JAVA_HOME/bin
    
    export M2_HOME=/Users/user/workspace/Tools/apache-maven-3.3.9
    export PATH=$PATH:$M2_HOME/bin

    After configuration is completed, check which file you configured it in (if it is /etc/profile), and then execute

    source /etc/profile

    reply
    0
  • 某草草

    某草草2017-05-27 17:43:45

    First

    /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
    

    Then

    brew install maven
    

    Just restart the terminal and it’s done

    reply
    0
  • Cancelreply