简体   繁体   English

Maven中的Java版本不匹配

[英]Java version mismatch in Maven

I'm having an odd problem, when attempting to build my application using Maven, on the command line . 在尝试使用Maven 在命令行上构建应用程序时,我遇到了一个奇怪的问题。 (Other questions I've seen on SO are referring to building within Eclipse, or some other IDE) (我在SO上看到的其他问题是指在Eclipse或其他一些IDE中进行构建)

When I attempt to build, maven complains that it cannot find Javac in tools.jar. 当我尝试构建时,maven抱怨它无法在tools.jar中找到Javac。 Looking at the given location, it is obvious that Maven is looking in the JRE directory, however, I seem unable to get Maven to point to the correct Java_home for my JDK - any ideas on how this should be done? 查看给定的位置,很明显Maven正在JRE目录中,但是,我似乎无法使Maven指向我的JDK的正确Java_home-关于如何执行此操作的任何想法?

Environment Overview 环境概况

JAVA_HOME=C:\jdk1.6.0_27
Path=C:\jdk1.6.0_27\bin;...... (showing the jdk is the first thing on the path)

D:\> javac -version
javac 1.6.0_27  <-- This is correct

D:\>java -version
java version "1.6.0_31"  <-- wtf? 

D:\>mvn -version
Apache Maven 2.2.1 (r801777; 2009-08-07 03:16:01+0800)
Java version: 1.6.0_31                       <--- This is the problem - Where
Java home: C:\Program Files (x86)\Java\jre6  <--- does Maven get this from?

Any light you could shed on this would be most welcome. 欢迎您提出任何建议。

Try Configure the toolchains.xml in your maven directory (eg D:\\maven-2.2.1\\conf) to your java version 尝试将您的maven目录(例如D:\\ maven-2.2.1 \\ conf)中的toolchains.xml配置为您的Java版本

<toolchains>
<toolchain>
    <type>jdk</type>
    <provides>
        <version>1.5</version> <!--This should be same as is configured via the toolchains plugin -->
        <vendor>ibm</vendor> <!--This should be same as is configured via the toolchains plugin -->
    </provides>
    <configuration>
        <jdkHome>C:\Program Files\Java\jdk1.5.0</jdkHome>
    </configuration>
</toolchain>
</toolchains>

have you looked at your your build-local.properties or build.properties? 您是否看过您的build-local.properties或build.properties? possibly still pointing to theJRE there. 可能仍然指向那里的JRE。 This has to purely be a build path issue somewhere along the path. 这纯粹是路径上某个地方的构建路径问题。

Sorry for listing this as an answer for i cant seem to add comments. 抱歉将此列为答案,因为我似乎无法添加评论。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM