Maven找不到具有适当JAVA_HOME的tools.jar

时间:2013-06-17 02:00:03

标签: windows maven javac java-home tools.jar

我在Windows机器上构建Maven项目时遇到了一些麻烦。我已经设置了我的JAVA_HOME环境变量,Maven找到了它。

以下是一些执行结果:

'哪个mvn'

/cygdrive/c/Program Files/Apache/apache-maven-3.0.5/bin/mvn

'mvn -version'

Apache Maven 3.0.5 (r01de14724cdef164cd33c7c8c2fe155faf9602da; 2013-02-19 05:51:28 0800)
Maven home: C:\Program Files\Apache\apache-maven-3.0.5
Java version: 1.6.0_45, vendor: Sun Microsystems Inc.
Java home: C:\Program Files\Java\jdk1.6.0_45\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 8", version: "6.2", arch: "amd64", family: "windows"

注意:它确实在这里找到了正确的JAVA_HOME路径!

与Maven建立:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.
0.2:compile (default-compile) on project sportbukkit-api: Compilation failure
[ERROR] Unable to locate the Javac Compiler in:
[ERROR] C:\Program Files\Java\jre6\..\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.

正如您所看到的,由于某种原因,它正在寻找完全错误的目录。如果需要更多信息或者您知道如何解决此问题,请告诉我们!谢谢!

1 个答案:

答案 0 :(得分:0)

尝试将您的JAVA_HOME设置为C:\Program Files\Java\jdk1.6.0_45而不是C:\Program Files\Java\jdk1.6.0_45\jre