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

今天创建maven项目时,出现了这个问题

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:testCompile (default-testCompile) on project springside-core: 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

我的机子环境:win10,jdk8,maven-3.5.3

解决方案:

  1. 在eclipse的菜单中,进入 Window > Preferences > Java > Installed JREs > Execution Environments,选择JavaSE-1.8, 在右侧选择jdk.把前面的选框选中,然后apply

  2. 然后在maven菜单中使用 “update project ...”,刷新maven配置。看一下是否 install命令是否能成功

  3. 如果上述两步还未成功,去系统的环境变量中,找path中是否存在:C:\Program Files (x86)\Common Files\Oracle\Java\javapath,然后把这一条路径删了。(这是在安装jdk8的时候iwin10自动新增的路径,我的是jdk8,存在的是这个路径,其他版本路径可能不一样,也有是的这个路径C:\ProgramData\Oracle\Java\javapath,但是大致类似)。

  4. 最后再刷新一下maven配置,"update project ...",ok成功了

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

如果还是不行就去检查一下Installed JREs的设置,使用的环境变量为jre

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


解决方法:

Installed JREs的设置修改为jdk即可.这里选择的其实是JAVA_HOME路径,jdk中包含jre

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

即可正常运行.

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


参考博客:点击打开链接点击打开链接



如果还是不行就去检查一下Installed JREs的设置,使用的环境变量为jre

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


解决方法:

Installed JREs的设置修改为jdk即可.这里选择的其实是JAVA_HOME路径,jdk中包含jre

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

即可正常运行.

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