简体   繁体   中英

How to use maven3 with java7 on OSX Mavericks?

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

您将想要在.bashrc添加以下内容:

export JAVA_HOME=$(/usr/libexec/java_home)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM