1

I installed Maven on macOS 10.12.6. Added environment to .bash_profile file:

export PS1="\h --- \t *************************** \w $ "
export JAVA_HOME=$(/usr/libexec/java_home)
export MAVEN_HOME=/Users/{user}/Documents/Path/Maven/maven_3.3.9
export GRADLE_HOME=/Users/{user}/Documents/Path/Gradle/gradle_6.1.1
export PATH=$PATH:$MAVEN_HOME/bin
export PATH=$GRADLE_HOME/bin:$PATH

After that I save it and set source .bash_profile command in Terminal. When I try in Terminal input mvn -v command I see:

-bash: mvn: command not found

When I input $MAVEN_HOME I see:

: No such file or directory/Path/Maven/maven_3.3.9

If I use echo $MAVEN_HOME command I see:

/Users/{user}/Documents/Path/Maven/maven_3.3.9

If I input this mvn I see:

-bash: mvn: command not found

JDK on Mac - $JAVA_HOME command in Terminal:

-bash: /Library/Java/JavaVirtualMachines/jdk1.8.0_241.jdk/Contents/Home: is a directory

Can you help me please to understand where I missed.

Yanick
  • 49
  • 5
  • 1
    Please don't use images to share textual information. See: https://meta.stackoverflow.com/questions/303812/discourage-screenshots-of-code-and-or-errors – AMC Jan 26 '20 at 19:32
  • I would recommend to install the most recent version of Maven not an old version... – khmarbaise Jan 27 '20 at 08:41

3 Answers3

1

Thank you very much for your answers, I fixed my problem just like that:

export PATH=/Users/{user}/Documents/Path/Maven/maven_3.3.9/bin:$PATH

After that everything worked as expected. If you think my method is not good, please tell me why?

Yanick
  • 49
  • 5
0

Since it is a maven 2+, export M2_HOME (see "What is the difference between M2_HOME and MAVEN_HOME")

And double check what echo $PATH returns after sourcing the .bashrc.
Make sure it:

  • includes $M2_HOME/bin
  • ls $M2_HOME/bin does exists.
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • See also https://www.dev2qa.com/how-to-set-java_home-maven_home-environment-variable-in-macos/ – VonC Jan 26 '20 at 21:02
0

Check this

1) Review your path, I think you are missing '$' character right before {user}

2) Review execution permission for 'maven_3.3.9/bin/mvn'

3) Make sure you are using Bash as Unix shell (and not zsh or another)

echo $SHELL
# output should look like: '/bin/bash'

4) If you are using bash then add maven's ENV variables to the file ~/.bashrc (or ~/.zshrc if you are using zsh)

5) 'source' your configuration

source ~/.bashrc

Notes

Alcastic
  • 374
  • 5
  • 15