12

This is the output from java -version:

java version "1.7.0_25" Java(TM) SE Runtime Environment (build 1.7.0_25-b15) Java HotSpot(TM) 64-Bit Server VM (build 23.25-b01, mixed mode)

This is the output from mvn -version:

Java version: 1.6.0_51, 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.8.4", arch: "x86_64", family: "mac"

How do I force Maven to use 1.7?

Robert Lauriston
  • 437
  • 3
  • 12

2 Answers2

20

Bug in Maven: http://jira.codehaus.org/browse/MNG-4226

Workaround:

echo JAVA_HOME=`/usr/libexec/java_home -v 1.7` | sudo tee -a /etc/mavenrc

Thanks to:

http://www.jayway.com/2013/03/08/configuring-maven-to-use-java-7-on-mac-os-x/

Robert Lauriston
  • 437
  • 3
  • 12
  • I had to do the same for Java 1.8 on mac os 10.9 : echo `JAVA_HOME=`/usr/libexec/java_home -v 1.8*` | sudo tee -a /etc/mavenrc` – Adrien Apr 24 '14 at 09:13
0

On Linux (at least), Maven uses $JAVA_HOME to locate the JVM it uses to run. Check that you have exported that environment variable, and that it points at the right place.

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216