maven install Unable to locate the Javac Compiler in: C:\Program Files\Java\jre7\..\lib\tools.jar

m2e (maven eclipse) 在运行一些命令时出现了无法compile(Unable to locate the Javac Compiler in:)
http://www.cnblogs.com/silentjesse/archive/2012/10/17/2727407.html

出现的bug提示

Unable to locate the Javac Compiler in:
C:\Program Files\Java\jre1.6.0_07\..\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.

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

可以看出m2e要求用于编译应该要用jdk且jdk是1.4及以上的版本才行

我在命令行下echo %JAVA_HOME%

检查了一下我的"JAVA_HOME"是C:\Program Files\Java\jdk1.6.0_20

那是哪里出错了呢,,这时我意识到我用的是m2e,那么我的运行时环境应该就是根据

eclipse(eclipse也有默认也有自己的运行时环境)指定的才是,,那么我只要把修改eclipse指定的运行时环境路径不就可以了,

于是

1、在eclipse里面修改 "window-->preferences->java->installed jres" 如图:

maven install Unable to locate the Javac Compiler in: C:\Program Files\Java\jre7\..\lib\tools.jar_第1张图片

edit the selected jre or add a new jre and select it  

the location should be "C:\Program Files\Java\jdk1.6.0_20\jre"

please don't close the "Edit JRE" dialog ,continue the second step.

2、remove the default jre system libraries and add all the jar in  the lib folder, lib subdirectory in  %JAVA_HOME%/jdk**/jre/

illustration:

 

maven install Unable to locate the Javac Compiler in: C:\Program Files\Java\jre7\..\lib\tools.jar_第2张图片

_^^_.......I wish this bug report message will help u....and please comment this ...

 

 

 

 

在用maven的这些日子以来,发现还有一种可能出现这种错误,就是你已经install了你的项目,,这时出现这种bug时,你需到仓库去把这些已存在的版本删除即可

你可能感兴趣的:(maven install Unable to locate the Javac Compiler in: C:\Program Files\Java\jre7\..\lib\tools.jar)