0

I've been trying to configure Maven and IntelliJ as I'd like to play with Spring MVC and Maven.

I've followed several guides, and still have issues.

Maven 3.2.5 is installed as is Java 1.6. This has ben confirmed by running -version on them from terminal:

mvn -version
Apache Maven 3.2.5 (12a6b3acb947671f09b81f49094c53f426d8cea1; 2014-12-14T17:29:23+00:00)
Maven home: /Users/SteveGreen/Development/apache-maven-3.2.5
Java version: 1.6.0_65, vendor: Apple Inc.
Java home: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
Default locale: en_US, platform encoding: MacRoman
OS name: "mac os x", version: "10.10.2", arch: "x86_64", family: "mac"

java version "1.6.0_65"
Java(TM) SE Runtime Environment (build 1.6.0_65-b14-466.1-11M4716)
Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-466.1, mixed mode)

I've then set the home variables as per guides 1,3,4,5,6,7 and 82. results are:

Steves-MacBook-Pro:~ SteveGreen$ echo $JAVA_HOME
/usr/libexec/java_home
Steves-MacBook-Pro:~ SteveGreen$ echo $M2_HOME
/Users/SteveGreen/Development/apache-maven-3.2.5
Steves-MacBook-Pro:~ SteveGreen$ echo $M2
/Users/SteveGreen/Development/apache-maven-3.2.5/bin
Steves-MacBook-Pro:~ SteveGreen$ echo $PATH
/Users/SteveGreen/Development/apache-maven-3.2.5/bin:/usr/local/b  `in:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin`

Another guide then suggested that I edit the bash profile. Which i dutifully did:

JAVA_HOME=/usr/libexec/java_home
M2_HOME=/Users/SteveGreen/Development/apache-maven-3.2.5
M2=/Users/SteveGreen/Development/apache-maven-3.2.5/bin
PATH=/Users/SteveGreen/Development/apache-maven-3.2.5/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin

and then another suggested changing launchd.conf:

setenv JAVA_VERSION 1.6
setenv JAVA_HOME /usr/libexec/java_home
setenv M2_HOME /Users/SteveGreen/Development/apache-maven-3.2.5

and os after all this I though, ha! I have you! But no, intelliJ installing me that there is 'No valid maven installation found . either set the home directory in the configuration dialog or se the M2_HOME variable on your system'

I've tried placing the install dir of Maven in the config dig but still no joy.

Can someone please release me form this misery and suggest a solution? Thanks!

Edit: After following the suggestion in the accepted answer I'm presented with:

    /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/bin/java --package -Dmaven.home=/Users/SteveGreen/Development/apache-maven-3.2.5 -Didea.modules.paths.file=/Users/SteveGreen/Library/Caches/IntelliJIdea13/Maven/idea-projects-state-96e43199.properties -Dclassworlds.conf=/var/folders/bj/bcfll90d46v1bsgb0bwqlzmr0000gp/T/idea-7288361697308129462-mvn.conf -Didea.launcher.port=7536 "-Didea.launcher.bin.path=/Applications/IntelliJ IDEA 13.app/bin" -Dfile.encoding=UTF-8 -classpath "/Users/SteveGreen/Development/apache-maven-3.2.5/boot/plexus-classworlds-2.5.2.jar:/Applications/IntelliJ IDEA 13.app/lib/idea_rt.jar" com.intellij.rt.execution.application.AppMain org.codehaus.classworlds.Launcher -Didea.version=13.1.3
Unrecognized option: --package
Could not create the Java virtual machine.

Process finished with exit code 1

again, any help is appreciated.

null
  • 3,469
  • 7
  • 41
  • 90
  • @Dave Newton, The passion before the edit was real :( "I've followed several guides, and still have come to the conclusion that maven is a dick" – null Apr 30 '15 at 18:25
  • http://stackoverflow.com/q/7053666/438992, etc. You can also set it in your project(s), which is what I do, since I have to use multiple versions of Maven (and Java, etc.) – Dave Newton Apr 30 '15 at 18:25
  • 1
    Neat. But it doesn't really belong in an SO question. – Dave Newton Apr 30 '15 at 18:26
  • Not sure it's neat, transparent angst :) I've tried setting it in the config of intelliJ and still the same result though...Death by Maven? – null Apr 30 '15 at 18:27
  • Dunno. Works fine for me. Also the bash profile should be exporting those environment variables, not just setting them. – Dave Newton Apr 30 '15 at 18:28
  • @DaveNewton, when you say exporting them, can you elaborate a touch please? Maybe that's where I'm going wrong. – null Apr 30 '15 at 18:29
  • `export JAVA_HOME=foo` but I doubt that's the issue. Even without a Maven installation IntelliJ's built-in Maven works fine for me, although it's an older version, 3.0.5. You also shouldn't use the built-in JDK if you're using Maven 3.3+ (or some version like that), the default is JDK 1.6. – Dave Newton Apr 30 '15 at 18:47
  • I grabbed the 3.2 version as I believe there's a dependency of sorts for requiring a later version of java for 3.3. I think I'll start with a fresh install and see what happens this time. – null Apr 30 '15 at 19:16
  • I'd ask a new question for a new problem. You should include *when* you actually get this error. – Dave Newton Apr 30 '15 at 19:37

1 Answers1

1

This is what I did when I had this issue, in Intellij Preferences, look for MAVEN then I set the Maven home directory directly as you can see in the screenshot.

Hope it helps!

jbarrueta
  • 4,907
  • 2
  • 20
  • 21
  • you legend! I guess i should find out why the M@_HOME Var is not being set but this works so thanks! – null Apr 30 '15 at 18:51
  • urm...don't suppose you know how to solve what I posted in the edit do you? – null Apr 30 '15 at 19:26