0

I am on mac and Installed maven using the brew install maven command. The maven was installed in /usr/local/Cellar/maven/3.3.9 path. Then i edited my ~/.bash_profile file and put the following entries

export M2_HOME="/usr/local/Cellar/maven/3.3.9"
export PATH="$PATH:$M2_HOME/bin"

now when i try mvn -version maven throws the error that

Error: Could not find or load main class org.codehaus.plexus.classworlds.launcher.Launcher

Did i configure it wrong ?

EDIT: Maven folder

$ tree -L 2 $M2_HOME
/usr/local/Cellar/maven/3.3.9
├── INSTALL_RECEIPT.json
├── LICENSE
├── NOTICE
├── README.txt
├── bin
│   ├── mvn
│   ├── mvn.cmd
│   ├── mvnDebug
│   ├── mvnDebug.cmd
│   └── mvnyjp
└── libexec
    ├── bin
    ├── boot
    ├── conf
    └── lib
Em Ae
  • 8,167
  • 27
  • 95
  • 162
  • Well that's really weird. Could you post your Maven home directory structure? There should be a `boot` folder containing a jar. – Tunaki Feb 01 '16 at 16:53
  • Updated the question with maven folder. There is no boot folder. – Em Ae Feb 01 '16 at 17:08
  • That is surely a problem. Never installed Maven on a Mac before. Are you sure you installed the version 3.3.9? Maybe your `brew` command is wrong? (never used that also). See this link: http://stackoverflow.com/q/8826881/1743880 – Tunaki Feb 01 '16 at 17:13
  • 1
    The installation is simply wrong. Just [download it from Maven site](http://maven.apache.org/download.cgi) and [unpackage it to for example](http://maven.apache.org/install.html) `/usr/share/java/` and put `/usr/share/java/apache-maven-3.3.9/bin` into your path and that's it.. – khmarbaise Feb 01 '16 at 18:17
  • Shall i report it as a brew bug ? – Em Ae Feb 01 '16 at 20:10

1 Answers1

0

I have also seen as an option:

Create a file ~/.MacOSX/environment.plist with:

{
  "M2_HOME" = "/usr/local/Cellar/maven/3.3.9/libexec";
  "M2" = "/usr/local/Cellar/maven/3.3.9/libexec/bin";
}

and restart / log back in. This would make tools like IntelliJ also pick it up.

However in my case, I found some other setup script had installed an export for M2_HOME in my .profile which broke the maven install.

JeeBee
  • 17,476
  • 5
  • 50
  • 60