Maven install 时出现Unable to locate the Javac Compiler 解决办法

问题描述:

在使用eclipse 运行 maven install的时候,出现以下错误:

[ERROR] Unable to locate the Javac Compiler in:

  D:\Program Files\Java\jre6\..\lib\tools.jar
Please ensure you are using JDK 1.4 or above and
not a JRE (the com.sun.tools.javac.Main class is required).
In most cases you can change the location of your Java
installation by setting the JAVA_HOME environment variable.

解决方法:

1.eclipse.ini文件中加了两行(一定要加在-vmargs之前,而且-vm后面有回车):

-vm
C:/Program Files/Java/jdk1.8.0_121/jre/bin/javaw.exe

Maven install 时出现Unable to locate the Javac Compiler 解决办法_第1张图片

2. Window -> Preferences -> Java -> Installed JREs, 点击"Add"按钮,选择默认的"Standard VM", 点击"Next >", 点击"JRE home"右边的"Directory"选择文件夹C:/Program Files/Java/jdk1.8.0_121,一路“确定”,回 到"Installed JREs"界面,在刚添加的"jdk1.8.0_121"打上勾。

Maven install 时出现Unable to locate the Javac Compiler 解决办法_第2张图片


3.选择目录树中的"Execution Environments", 点选界面左侧的"J2SE-1.5",然后在右侧点选"jdk1.5.0_16"。

Maven install 时出现Unable to locate the Javac Compiler 解决办法_第3张图片

4.重启Eclipse,大功告成!

你可能感兴趣的:(Maven install 时出现Unable to locate the Javac Compiler 解决办法)