No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK错误

本文介绍了在命令行中执行Maven项目编译时遇到的一个常见错误:未找到编译器,可能是运行在JRE而非JDK上。通过检查并正确配置JAVA_HOME环境变量解决了该问题。

在命令行中执行编译(mvn compile)maven项目时,提示[ERROR] No compiler is providedin this environment. Perhaps you are running on a JRE rather than a JDK?错误信息,具体详细如下

[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: 0.787 s
[INFO] Finished at: 2018-03-11T15:33:10+08:00
[INFO] Final Memory: 8M/154M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project simple: Compilation failure
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
[ERROR]
[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

 刚开始搞maven项目,在网上搜索下资料发现都是基于eclipse开发的,而我的是直接使用mvn在命令行执行的,不适合我的情况,但是我想也是jdk的配置问题。后来我又检查了下jdk的配置,发现我只配置了path的内容,没有配置JAVA_HOME,于是我试着配置了,然后重新打开一个命令行窗口重新执行命令,发现问题解决了。原来是没有配置JAVA_HOME的原因,JAVA_HOME对于使用eclipse工具开发可有可无,但是如果使用最基本的命令行操作,它还是需要配置上的。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值