eclipse下maven打包失败(Please ensure you are using JDK 1.4 or above and not ......

在eclipse下用maven编译时,可能会失败,报出以下提示:

[ERROR] Unable to locate the Javac Compiler in:
[ERROR] C:\Program Files\Java\jre1.8.0_72\..\lib\tools.jar
[ERROR] Please ensure you are using JDK 1.4 or above and
[ERROR] not a JRE (the com.sun.tools.javac.Main class is required).
[ERROR] In most cases you can change the location of your Java
[ERROR] installation by setting the JAVA_HOME environment variable.
[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
[ERROR] 
[ERROR] After correcting the problems, you can resume the build with the command

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

修改步骤如下:

1.保证JAVA_HOME和MAVEN_HOME指向正确

2.尝试修改eclipse.ini,加入如下语句 
-vm
C:\Program Files\Java\jdk1.8.0_72\jre\bin\javaw.exe

3.在Eclipse->Window->Preferences->Java->Installed JREs->Add...->Standard VM里,JRE home选择JDK的目录

eclipse下maven打包失败(Please ensure you are using JDK 1.4 or above and not ......_第1张图片

4.设置Default VM arguments

-Dmaven.multiModuleProjectDirectory=$M2_HOME

eclipse下maven打包失败(Please ensure you are using JDK 1.4 or above and not ......_第2张图片

好了,不出意外,重新启动eclipse,应该会好。

你可能感兴趣的:(#,eclipse)