Maven报错Please ensure you are using JDK 1.4 or above and not a JRE解决方法!

在eclipse下用maven编译时,很有可能出现以下错误:

Please ensure you are using JDK 1.4 or above and
not a JRE (the com.sun.tools.javac.Main class is required).

// 请确保您使用的是JDK 1.4或以上版本

不是一个JRE(com.sun.tools.javac。主类是必需的)。//

原因:eclipse默认是使用jre作为运行环境,而maven编译需要jdk作为运行环境。

我们只要做如下更改即可。

在eclipse中打开,

window -> preferences -> Java -> installed jres,点击add->选择Standard VM,新加一个环境,设为默认环境,注意location选择为你的jdk目录。

然后再去编译你的项目,就OK了。

如果还是不行,就在你的项目上右击,build path -> configure build path,编辑JRE System Library,选择刚才新建的默认环境

再去编译即可。

原文地址:https://www.cnblogs.com/shihua513/p/6163682.html