尝试编译代码时发现错误

时间:2014-05-21 09:25:32

标签: java maven

当我尝试maven运行测试代码时,会弹出此错误:

[INFO] Finished at: Wed May 21 17:17:47 CST 2014 [INFO] Final Memory: 12M/61M 
[INFO]------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.0:compile (default-compile) on project java-checks: 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

我从Eclipse运行Maven并在Preference > Java > Installed JREs中设置了一个JDK,但我仍然遇到了这个错误。

有什么解决方案?

2 个答案:

答案 0 :(得分:0)

您尚未正确设置JAVA_HOME变量,或者$JAVA_HOME/bin%JAVA_HOME%\bin)不在您的PATH变量上(我建议您将其放在PATH变量上{{1}}环境变量的开头。)

答案 1 :(得分:0)

在#34;安装JRE"中设置JDK是不够的。当你从Eclipse运行Maven时。 Eclipse本身也必须在JDK中运行。

要确保这一点,请编辑Eclipse文件夹中的eclipse.ini。像

一样添加somtehing
-vm
C:/Program Files/Java/jdk1.7.0_51/bin/javaw.exe

当然有正确的JDK路径。