Question

I installed maven3 on Mavericks by Macports. It's working well but using java 1.6. How could I change to use java 7 instead?

Maven3 is installed but using java 1.6:

$ mvn -version
Apache Maven 3.0.5 (r01de14724cdef164cd33c7c8c2fe155faf9602da; 2013-02-19 13:51:28+0000)
Maven home: /opt/local/share/java/maven3
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.9.2", arch: "x86_64", family: "mac"

Java 7 is also installed:

$ 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)

Java 7 path:

$ which java
/usr/bin/java
$ ls -lah /usr/bin/java
lrwxr-xr-x  1 root  wheel    74B 26 Oct 13:33 /usr/bin/java -> /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java

What's the difference in the two java paths?

  • /System/Library/Java/JavaVirtualMachines
  • /System/Library/Frameworks/JavaVM.framework/Versions
Was it helpful?

Solution

You'll want to add something like the following to your .bashrc:

export JAVA_HOME=$(/usr/libexec/java_home)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top