rogueleaderr
rogueleaderr

Reputation: 4799

Error trying to install Maven on OSX Lion

[UPDATE] Was just an idiot mistake. See end for solution.

I am trying to install Maven on my 2011 Macbook Pro. Unfortunately I don't know Java at all, but I am trying to muddle my way through some tools built in Java, and they imply that using Maven to install them will make things easier.

I followed the Maven install instructions here: http://maven.apache.org/download.html#Installation.

I...

1) downloaded Maven, 2) unzipped it, 3) put it in /usr/local/apache-maven-3.0.3/ 4) added

export M2_HOME=/usr/local/apache-maven/apache-maven-3.0.3`
export M2=$M2_HOME/bin`
export PATH=$M2:$PATH`

to my .zshrc file

5) typed mvn --version and got back:

Exception in thread "main" java.lang.NoClassDefFoundError: org/codehaus/plexus/classworlds/launcher/Launcher
Caused by: java.lang.ClassNotFoundException: org.codehaus.plexus.classworlds.launcher.Launcher
  at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
  at java.security.AccessController.doPrivileged(Native Method)
  at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
  at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:247)

I found a couple of blog posts (http://steveswinsburg.wordpress.com/2011/03/09/java-update-broke-my-maven/) that described how to fix a similar sounding error, but those seem to be problems with upgrading Maven 2 to Maven 3. Afaik, I've never even had Maven 2. I nevertheless followed the directions in that post, and am still getting the exact same error.

Please help!

Also does anyone know a good resource for a beginner to learn how the "Java ecosystem", i.e. Maven, classpaths, etc works? I tried some "Learn Java" videos at udemy.com, but they were all about the syntax of programming in Java, whereas most of the problems I've been having have been around figuring out how to make existing Java apps run in the first place, or how to follow basic jargon-filled documentation.

[SOLUTION]

Summary...idiot mistake.

While following the Maven installation directions, I cut-n-pasted the line "In a command terminal, add the M2_HOME environment variable, e.g. export M2_HOME=/usr/local/apache-maven/apache-maven-3.0.3", not realizing that I had actually installed my unzipped file in /usr/local/apache-maven-3.0.3.

Once again, scumbag brain "saves time" by refusing to automatically read apparently redundant information, so I didn't notice that apache's example expected I had nested the install inside a second folder.

Fixing the .zshrc line to read `export M2_HOME=/usr/local/apache-maven-3.0.3' fixed the problem.

Thanks ivantod for pointing out my error.

Upvotes: 2

Views: 3166

Answers (1)

user36476
user36476

Reputation: 58

Mac OS X Lion ships with maven already installed on it @ /usr/share/maven.

You only have to type java on terminal to install java and export JAVA_HOME in ~/.profile to /System/Library/Frameworks/JavaVM.framework/Home. Optionally you can set other parameters like MAVEN_OPTS and JAVA_OPTS.

Upvotes: 2

Related Questions