0

i have the following in my .bash_profile

export M2_HOME=/usr/local/Cellar/maven/3.3.3
export M2=$M2_HOME/bin
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/jre
export PATH=/usr/bin:/usr/sbin:/bin:/sbin
export PATH=$M2:$PATH
export PATH=$JAVA_HOME/bin:$PATH

This is a direct copy and paste from terminal

Last login: Mon May 25 20:58:46 on ttys000
Harleys-MacBook-Pro:~ chiphansel$ open .bash_profile
Harleys-MacBook-Pro:~ chiphansel$ java -version
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)
Harleys-MacBook-Pro:~ chiphansel$ mvn -version
Error: Could not find or load main class org.codehaus.plexus.classworlds.launcher.Launcher
Harleys-MacBook-Pro:~ chiphansel$ echo $PATH
/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/jre/bin:/usr/local/Cellar/maven/3.3.3/bin:/usr/bin:/usr/sbin:/bin:/sbin
Harleys-MacBook-Pro:~ chiphansel$ 

It finds java is set up correctly (I think) and maven is the correct directory. I am new to Mac and I am finding my lack of knowledge very frustrating.

Thanks in advance.

1 Answers1

0

Welcome to the Mac world! Looks like you're using Homebrew. If yes, you don't need to export $M2_HOME and $M2. But your Homebrew cellars should be added to $PATH correctly.

$ echo $PATH
/usr/local/bin:/usr/bin:/usr/sbin:/bin:/sbin

/usr/local/bin is everything Homebrew needs.

$ echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home

And try to remove the /jre at the end of your $JAVA_HOME.

Please don't add $JAVA_HOME to $PATH.

Marc
  • 2,072
  • 2
  • 23
  • 36