我在 运行 ant build 上收到“**** WRONG JAVA VERSION ****”

I am getting '**** WRONG JAVA VERSION ****' on running ant build

我的问题不是this question,因为我在java版本中没有差异。 在我安装 java 1.8.45(jdk 和 jre)后,基于 运行 'ant clean all' 的构建失败。 它说:

**** WRONG JAVA VERSION ****

Environment check failed: You are using a not supported version of Java. Please make sure you are using Java version 1.7 or later. Your current Java version is: 1.8.0_45

TIP: If you are using eclipse you can configure a different JVM under Preferences->Java->Installed JREs.

我的系统详情:
Java版本:

java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)

Javac版本:

javac 1.8.0_45

蚂蚁版:

Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=128M; support was removed in 8.0
Apache Ant(TM) version 1.9.1 compiled on May 15 2013

正在将 echo 添加到构建文件中:

[echo] java.version  = 1.8
[echo] java.home     = C:\Program Files\Java\jdk1.8.0_45\jre
[echo] C:\HM\GOEP_Hybris_R2\bin\platform/tomcat/bin

蚂蚁诊断

Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=128M; support was removed in 8.0
------- Ant diagnostics report -------
Apache Ant(TM) version 1.9.1 compiled on May 15 2013

-------------------------------------------
 Implementation Version
-------------------------------------------
core tasks     : 1.9.1 in file:/C:/HM/GOEP_Hybris_R2/bin/platform/apache-ant-1.9.1/lib/ant.jar

-------------------------------------------
 ANT PROPERTIES
-------------------------------------------
ant.version: Apache Ant(TM) version 1.9.1 compiled on May 15 2013
ant.java.version: 1.8
Is this the Apache Harmony VM? no
Is this the Kaffe VM? no
Is this gij/gcj? no
ant.core.lib: C:\HM\GOEP_Hybris_R2\bin\platform\apache-ant-1.9.1\lib\ant.jar
ant.home: C:\HM\GOEP_Hybris_R2\bin\platform\apache-ant-1.9.1

-------------------------------------------
 ANT_HOME/lib jar listing
-------------------------------------------
ant.home: C:\HM\GOEP_Hybris_R2\bin\platform\apache-ant-1.9.1
ant-antlr.jar (11567 bytes)
ant-apache-bcel.jar (15059 bytes)
ant-apache-bsf.jar (9747 bytes)
ant-apache-log4j.jar (8592 bytes)
ant-apache-oro.jar (9711 bytes)
ant-apache-regexp.jar (9571 bytes)
ant-apache-resolver.jar (9642 bytes)
ant-apache-xalan2.jar (8102 bytes)
ant-commons-logging.jar (9720 bytes)
ant-commons-net.jar (91275 bytes)
ant-jai.jar (28224 bytes)
ant-javamail.jar (13768 bytes)
ant-jdepend.jar (13821 bytes)
ant-jmf.jar (12278 bytes)
ant-jsch.jar (46514 bytes)
ant-junit.jar (112845 bytes)
ant-junit4.jar (13065 bytes)
ant-launcher.jar (18336 bytes)
ant-netrexx.jar (16272 bytes)
ant-swing.jar (13244 bytes)
ant-testutil.jar (20998 bytes)
ant.jar (1997485 bytes)

-------------------------------------------
 USER_HOME/.ant/lib jar listing
-------------------------------------------
user.home: C:\Users\mohd.farrukh.chishti
No such directory.

-------------------------------------------
 Tasks availability
-------------------------------------------
image : Missing dependency javax.media.jai.PlanarImage
sshexec : Missing dependency com.jcraft.jsch.Logger
scp : Missing dependency com.jcraft.jsch.Logger
sshsession : Missing dependency com.jcraft.jsch.Logger
jdepend : Missing dependency jdepend.xmlui.JDepend
A task being missing/unavailable should only matter if you are trying to use it

-------------------------------------------
 org.apache.env.Which diagnostics
-------------------------------------------
Not available.
Download it at http://xml.apache.org/commons/

-------------------------------------------
 XML Parser information
-------------------------------------------
XML Parser : com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl
XML Parser Location: unknown
Namespace-aware parser : com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser
Namespace-aware parser Location: unknown

-------------------------------------------
 XSLT Processor information
-------------------------------------------
XSLT Processor : com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl
XSLT Processor Location: unknown

-------------------------------------------
 System properties
-------------------------------------------
java.runtime.name : Java(TM) SE Runtime Environment
sun.boot.library.path : C:\Program Files\Java\jdk1.8.0_45\jre\bin
java.vm.version : 25.45-b02
ant.library.dir : C:\HM\GOEP_Hybris_R2\bin\platform\apache-ant-1.9.1\lib
java.vm.vendor : Oracle Corporation
java.vendor.url : http://java.oracle.com/
path.separator : ;
java.vm.name : Java HotSpot(TM) 64-Bit Server VM
file.encoding.pkg : sun.io
user.script :
user.country : US
sun.java.launcher : SUN_STANDARD
sun.os.patch.level : Service Pack 1
java.vm.specification.name : Java Virtual Machine Specification
user.dir : C:\HM\GOEP_Hybris_R2\bin\platform
java.runtime.version : 1.8.0_45-b14
java.awt.graphicsenv : sun.awt.Win32GraphicsEnvironment
java.endorsed.dirs : C:\Program Files\Java\jdk1.8.0_45\jre\lib\endorsed
os.arch : amd64
java.io.tmpdir : C:\Users\MOHDFA~1.CHI\AppData\Local\Temp\
line.separator :

java.vm.specification.vendor : Oracle Corporation
user.variant :
os.name : Windows 7
ant.home : C:\HM\GOEP_Hybris_R2\bin\platform\apache-ant-1.9.1
sun.jnu.encoding : Cp1252
java.library.path : C:\Program Files\Java\jdk1.8.0_45\bin;C:\windows\Sun\Java\bin;C:\windows\system32;C:\windows;C:\HM\GOEP_Hybris_R2\bin\platform\apa
che-ant-1.9.1\bin;C:\windows\System32;C:\Program Files\Java\jdk1.8.0_45\bin;C:\apache-maven-3.1.1\bin;C:\oraclexe\app\oracle\product.2.0\server\bin
;;C:\ProgramData\Oracle\Java\javapath;C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;.
java.specification.name : Java Platform API Specification
java.class.version : 52.0
sun.management.compiler : HotSpot 64-Bit Tiered Compilers
os.version : 6.1
user.home : C:\Users\mohd.farrukh.chishti
user.timezone : Asia/Calcutta
java.awt.printerjob : sun.awt.windows.WPrinterJob
java.specification.version : 1.8
file.encoding : Cp1252
user.name : mohd.farrukh.chishti
java.class.path : C:\HM\GOEP_Hybris_R2\bin\platform\apache-ant-1.9.1\lib\ant-launcher.jar;C:\HM\GOEP_Hybris_R2\bin\platform\apache-ant-1.9.1\lib\ant-a
ntlr.jar;C:\HM\GOEP_Hybris_R2\bin\platform\apache-ant-1.9.1\lib\ant-apache-bcel.jar;C:\HM\GOEP_Hybris_R2\bin\platform\apache-ant-1.9.1\lib\ant-apache-
bsf.jar;C:\HM\GOEP_Hybris_R2\bin\platform\apache-ant-1.9.1\lib\ant-apache-log4j.jar;C:\HM\GOEP_Hybris_R2\bin\platform\apache-ant-1.9.1\lib\ant-apache-
oro.jar;C:\HM\GOEP_Hybris_R2\bin\platform\apache-ant-1.9.1\lib\ant-apache-regexp.jar;C:\HM\GOEP_Hybris_R2\bin\platform\apache-ant-1.9.1\lib\ant-apache
-resolver.jar;C:\HM\GOEP_Hybris_R2\bin\platform\apache-ant-1.9.1\lib\ant-apache-xalan2.jar;C:\HM\GOEP_Hybris_R2\bin\platform\apache-ant-1.9.1\lib\ant-
commons-logging.jar;C:\HM\GOEP_Hybris_R2\bin\platform\apache-ant-1.9.1\lib\ant-commons-net.jar;C:\HM\GOEP_Hybris_R2\bin\platform\apache-ant-1.9.1\lib\
ant-jai.jar;C:\HM\GOEP_Hybris_R2\bin\platform\apache-ant-1.9.1\lib\ant-javamail.jar;C:\HM\GOEP_Hybris_R2\bin\platform\apache-ant-1.9.1\lib\ant-jdepend
.jar;C:\HM\GOEP_Hybris_R2\bin\platform\apache-ant-1.9.1\lib\ant-jmf.jar;C:\HM\GOEP_Hybris_R2\bin\platform\apache-ant-1.9.1\lib\ant-jsch.jar;C:\HM\GOEP
_Hybris_R2\bin\platform\apache-ant-1.9.1\lib\ant-junit.jar;C:\HM\GOEP_Hybris_R2\bin\platform\apache-ant-1.9.1\lib\ant-junit4.jar;C:\HM\GOEP_Hybris_R2\
bin\platform\apache-ant-1.9.1\lib\ant-launcher.jar;C:\HM\GOEP_Hybris_R2\bin\platform\apache-ant-1.9.1\lib\ant-netrexx.jar;C:\HM\GOEP_Hybris_R2\bin\pla
tform\apache-ant-1.9.1\lib\ant-swing.jar;C:\HM\GOEP_Hybris_R2\bin\platform\apache-ant-1.9.1\lib\ant-testutil.jar;C:\HM\GOEP_Hybris_R2\bin\platform\apa
che-ant-1.9.1\lib\ant.jar;C:\Program Files\Java\jdk1.8.0_45\lib\tools.jar
java.vm.specification.version : 1.8
sun.arch.data.model : 64
java.home : C:\Program Files\Java\jdk1.8.0_45\jre
sun.java.command : org.apache.tools.ant.launch.Launcher -diagnostics
java.specification.vendor : Oracle Corporation
user.language : en
awt.toolkit : sun.awt.windows.WToolkit
java.vm.info : mixed mode
java.version : 1.8.0_45
java.ext.dirs : C:\Program Files\Java\jdk1.8.0_45\jre\lib\ext;C:\windows\Sun\Java\lib\ext
sun.boot.class.path : C:\Program Files\Java\jdk1.8.0_45\jre\lib\resources.jar;C:\Program Files\Java\jdk1.8.0_45\jre\lib\rt.jar;C:\Program Files\Java\j
dk1.8.0_45\jre\lib\sunrsasign.jar;C:\Program Files\Java\jdk1.8.0_45\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.8.0_45\jre\lib\jce.jar;C:\Program File
s\Java\jdk1.8.0_45\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.8.0_45\jre\lib\jfr.jar;C:\Program Files\Java\jdk1.8.0_45\jre\classes
sun.stderr.encoding : cp437
java.vendor : Oracle Corporation
file.separator : \
java.vendor.url.bug : http://bugreport.sun.com/bugreport/
sun.cpu.endian : little
sun.io.unicode.encoding : UnicodeLittle
sun.stdout.encoding : cp437
sun.desktop : windows
sun.cpu.isalist : amd64

-------------------------------------------
 Temp dir
-------------------------------------------
Temp dir is C:\Users\MOHDFA~1.CHI\AppData\Local\Temp\
Temp dir is writeable
Temp dir alignment with system clock is 108 ms

-------------------------------------------
 Locale information
-------------------------------------------
Timezone India Standard Time offset=19800000

-------------------------------------------
 Proxy information
-------------------------------------------
Java1.5+ proxy settings:
Direct connection

清除 build.xml 的标签:

<target name="clean" description="Cleans platform and all extensions">
        <callback extname="" target="before_clean"/>
        <clean/>
        <callback extname="" target="after_clean"/>
    </target>

与针对同一问题的其他开放线程不同,在这种情况下,所有版本都是一致的,并且 ant 正在确认它。尽管如此,它还是给出了这个问题。有什么见解吗?

知道了!!!
java 1.8.45 与 ant 1.9.1 不兼容。 切换到 java 1.7.67(jdk 和 jre),一切正常。

我们可以配置java版本util.xml 地点:${HYBRIS_BIN_DIR}\platform\resources\ant\util.xml .

考虑我的版本是1.8,在checkenv下配置java版本为contains string="${java.version}" substring="1.8" />

            <if>
            <not>
                <or>
                    <contains string="${java.version}" substring="1.7" />
                    <contains string="${java.version}" substring="1.8" />
                </or>
            </not>
            <then>