[英]Maven 3.2.1 on Mac OSX 10.9.2 is incorrectly using JRE 7 and not JDK 7
I have tried following the instructions at After Installing Java JDK 7 For Mac OS X - mvn -version still shows java version 1.6.0_31 but they do not fix my issue. 我已尝试按照在Mac OS X上安装Java JDK 7之后的说明进行操作-mvn -version仍显示Java版本1.6.0_31,但它们不能解决我的问题。 :-(
:-(
When I run: 当我跑步时:
mvn clean install
I get the following issue: 我收到以下问题:
[INFO] Scanning for projects...
[INFO]
[INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building JBehave JUnit Runner 1.2.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ jbehave-junit-runner ---
[INFO] Deleting /Users/skurlow/IdeaProjects/mygithubforks/jbehave-junit-runner/target
[INFO]
[INFO] --- maven-enforcer-plugin:1.0:enforce (enforce-maven) @ jbehave-junit-runner ---
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ jbehave-junit-runner ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/skurlow/IdeaProjects/mygithubforks/jbehave-junit-runner/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ jbehave-junit-runner ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 5 source files to /Users/skurlow/IdeaProjects/mygithubforks/jbehave-junit-runner/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.164 s
[INFO] Finished at: 2014-04-18T07:25:53+10:00
[INFO] Final Memory: 11M/126M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project jbehave-junit-runner: Compilation failure
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
I have Oracle's JDK7 installed: 我安装了Oracle的JDK7:
echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/jdk1.7.0_55.jdk/Contents/Home
I added to my pom.xml because maven was some how deciding to use source and target of 1.5 rather than 1.7: 我将其添加到pom.xml中是因为maven是如何决定使用1.5而不是1.7的源和目标的:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
When I run: 当我跑步时:
mvn clean install -X
I see it is telling me that JRE is being used and not the JDK. 我看到它告诉我正在使用JRE,而不是JDK。 But I cannot for the life of me change maven to use JDK instead of JRE.
但是我无法终生改变Maven以使用JDK而不是JRE。 :-(
:-(
Apache Maven 3.2.1 (ea8b2b07643dbb1b84b6d16e1f08391b666bc1e9; 2014-02-15T04:37:52+10:00)
Maven home: /Users/skurlow/tools/apache-maven-3.2.1
Java version: 1.7.0_55, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.7.0_55.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.9.2", arch: "x86_64", family: "mac"
[INFO] Error stacktraces are turned on.
The output of running: 运行的输出:
mvn --version
is: 是:
Apache Maven 3.2.1 (ea8b2b07643dbb1b84b6d16e1f08391b666bc1e9; 2014-02-15T04:37:52+10:00)
Maven home: /Users/skurlow/tools/apache-maven-3.2.1
Java version: 1.7.0_55, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.7.0_55.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.9.2", arch: "x86_64", family: "mac"
The output of running: 运行的输出:
javac -version
is: 是:
javac 1.7.0_55
I have had the same error in the windows environment. 我在Windows环境中遇到了相同的错误。 The solution was to set the JAVA_HOME environment variable to the JDK path and not JRE path.
解决方案是将JAVA_HOME环境变量设置为JDK路径而不是JRE路径。 This was:
这是:
JAVA_HOME = C:\\Program Files\\Java\\jdk1.7.0_55
JAVA_HOME = C:\\ Program Files \\ Java \\ jdk1.7.0_55
PATH = %JAVA_HOME%\\bin
PATH =%JAVA_HOME%\\ bin
Ensure that you follow maven install instructions for OSX. 确保遵循OSX的maven安装说明。 for you this might be:
对您来说,这可能是:
Make sure that JAVA_HOME is set to the location of your JDK, eg export JAVA_HOME=/usr/java/jdk1.7.0_51 and that $JAVA_HOME/bin is in your PATH environment variable. 确保将JAVA_HOME设置为JDK的位置,例如export JAVA_HOME = / usr / java / jdk1.7.0_51,并且$ JAVA_HOME / bin位于PATH环境变量中。
The fix was to delete tools.jar from my home directory in ~/Library/Java/Extensions 解决方法是从我的主目录中的〜/ Library / Java / Extensions中删除tools.jar
For an unknown reason I had a JDK5 version of it lying around in there. 由于一个未知的原因,我在那里有一个JDK5版本。
You can also check and remove it if you have it in the root folder in /Library/Java/Extensions 如果您在/ Library / Java / Extensions的根文件夹中有此文件,也可以检查并删除它
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.