【发布时间】:2013-02-19 15:40:07
【问题描述】:
我在 Eclipse 中使用 maven 创建了一个 webapp 项目。当我在命令提示符下运行命令 mvn package 时,它显示以下错误。
[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: 4.310s
[INFO] Finished at: Tue Mar 05 14:32:23 IST 2013
[INFO] Final Memory: 16M/218M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.0:compile (default-compile) on project Compilation fa
ilure
[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
我试图改变 jdk 和 jre。但不工作。仍然显示相同的错误
【问题讨论】:
-
在控制台中,你的
javac输出是什么? -
你跑
mvn -e package了吗? -
您应该仔细阅读错误信息:[ERROR] ***此环境中未提供编译器。也许您在 JRE 而不是 JDK 上运行?*****。我建议检查 JAVA_HOME 以及它是否指向 JDK 和 **NOT 指向 JRE。
-
该消息与您的帖子有矛盾之处。
-
在命令行上,执行
mvn -version。确保“Java home”之后列出的 java 安装是 jdk