在运行ant build时,我得到’**** WRONG JAVA VERSION ****’

我的问题不是
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

Ant Vesion:

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

ant -diagnostics

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\11.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),一切正常.

点赞