如何在OSX Mavericks上使用maven 3和java 7?

时间:2014-03-15 18:24:26

标签: java maven-3 osx-mavericks macports

我通过Macports在Mavericks上安装了maven3。它运行良好但使用java 1.6。我怎样才能改为使用java 7?

已安装Maven3,但使用的是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:

$ 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路径:

$ 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

两条java路径的区别是什么?

  • /系统/库/爪哇/ JavaVirtualMachines
  • /System/Library/Frameworks/JavaVM.framework/Versions

1 个答案:

答案 0 :(得分:0)

您需要向.bashrc添加以下内容:

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