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

原文链接:这里
0.前言

IDEA中在使用maven的指令mvn clean install 的时候,出现这个报错,网上有的答案说是jdk配错了,我看了一下,java是正常使用的状态,这又犯难了。。

java版本:

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

mvn -v :

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

这样看不出问题了,打开本机自带的cmd,输入 mvn -v 后,出现如下:

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

大概的意思是:JAVA_HOME环境没有正确定义的意思,问题还是出在JAVA_HOME上,可是我的java 明明可以正常运行,为什么会报这个错误呢?

问题出在maven 上,在windows上,maven必须识别JAVA_HOME这个环境变量,没有的话就自己给你拼出一个(还TM是正确的),而且不认path里的定义的jdk的环境变量,没有办法,还是得用最原始的方法。

1.解决办法

我们打开电脑的环境变量,选择新建一个新的环境变量,

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?

注意,这个地方的变量值就不要写到bin一级,经过我的尝试,只能写到jdk一级。

然后,我们打开 path环境变量,按照下面方式填入,注意后面加上 bin。然后点击确定。

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

然后重新打开一个cmd窗口,输入mvn -v,可以看到这个时候java的地址显示已经变了。

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

把IDEA关掉重新打开,执行mvn clean install 发现可以正常打包运行了。

上一篇:图像的基本处理(五)ImageDraw 模块的使用


下一篇:JDK1.8的lib相关jar