0

我有一个具有 java 编译目标的 ant 构建文件。相同的 Eclipse 发行版工作正常,并成功运行其他 ant 构建文件。但是在这个特定的工作空间中;当我运行 ant 目标时,它失败并出现以下错误:

    [javac] C:\MyProject\scripts\build.xml:119: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
    [javac] Compiling 1 source file to C:\MyProject\build
    [javac] Compiling 9 source files to C:\MyProject\build
    [javac] java.lang.NoClassDefFoundError: com/sun/tools/javac/Main
    [javac] Exception in thread "main" Could not find the main class: com.sun.tools.javac.Main.  Program will exit.

BUILD FAILED

我也尝试过从命令提示符运行构建文件并看到同样的问题。这是否指向任何明显的问题。日食设置了蚂蚁路径,我已经在日食中检查了它指向正确的位置。

我还验证了 tools.jar 也包含在项目路径中。

系统信息:

System info:
Windows 7 Enterprise edition, 64 bit
JDK 1.6b35
ANT 1.8.3

任何建议都会有所帮助。

==================================================== ===========================

根据@MickJ 的请求,我还在使用诊断选项运行构建目标时添加输出(我在 Eclipse 中的任何构建运行配置中添加了 -diagnostics)

------- Ant diagnostics report -------
Apache Ant(TM) version 1.8.2 compiled on December 20 2010
-------------------------------------------
 Implementation Version
-------------------------------------------
core tasks     : 1.8.2 in file:/C:/ToolBox/apps/dumps/Eclipse3.7/plugins/org.apache.ant_1.8.2.v20120109-1030/lib/ant.jar
-------------------------------------------
 ANT PROPERTIES
-------------------------------------------
ant.version: Apache Ant(TM) version 1.8.2 compiled on December 20 2010
ant.java.version: 1.6
Is this the Apache Harmony VM? no
Is this the Kaffe VM? no
Is this gij/gcj? no
ant.core.lib: C:\ToolBox\apps\dumps\Eclipse3.7\plugins\org.apache.ant_1.8.2.v20120109-1030\lib\ant.jar
ant.home: C:\ToolBox\apps\dumps\Eclipse3.7\plugins\org.apache.ant_1.8.2.v20120109-1030
-------------------------------------------
 ANT_HOME/lib jar listing
-------------------------------------------
ant.home: C:\ToolBox\apps\dumps\Eclipse3.7\plugins\org.apache.ant_1.8.2.v20120109-1030
ant-antlr.jar (5989 bytes)
ant-apache-bcel.jar (9097 bytes)
ant-apache-bsf.jar (4249 bytes)
ant-apache-log4j.jar (3361 bytes)
ant-apache-oro.jar (40276 bytes)
ant-apache-regexp.jar (4106 bytes)
ant-apache-resolver.jar (4418 bytes)
ant-apache-xalan2.jar (2633 bytes)
ant-commons-logging.jar (4207 bytes)
ant-commons-net.jar (85302 bytes)
ant-jai.jar (22684 bytes)
ant-javamail.jar (8167 bytes)
ant-jdepend.jar (8477 bytes)
ant-jmf.jar (7093 bytes)
ant-jsch.jar (40320 bytes)
ant-junit.jar (101811 bytes)
ant-junit4.jar (7517 bytes)
ant-launcher.jar (12567 bytes)
ant-netrexx.jar (10656 bytes)
ant-swing.jar (7847 bytes)
ant-testutil.jar (15576 bytes)
ant.jar (1927228 bytes)
-------------------------------------------
 USER_HOME/.ant/lib jar listing
-------------------------------------------
user.home: C:\Users\oo018c
No such directory.
-------------------------------------------
 Tasks availability
-------------------------------------------
image : Missing dependency javax.media.jai.PlanarImage
sshexec : Missing dependency com.jcraft.jsch.Logger
wlrun : Not Available (the implementation class is not present)
scp : Missing dependency com.jcraft.jsch.Logger
stlist : Not Available (the implementation class is not present)
sshsession : Missing dependency com.jcraft.jsch.Logger
starteam : Not Available (the implementation class is not present)
stlabel : Not Available (the implementation class is not present)
jdepend : Missing dependency jdepend.xmlui.JDepend
stcheckin : Not Available (the implementation class is not present)
stcheckout : Not Available (the implementation class is not present)
ejbc : Not Available (the implementation class is not present)
wlstop : Not Available (the implementation class is not present)
ddcreator : Not Available (the implementation class is not present)
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.6.0_37\jre\bin
java.vm.version : 20.12-b01
ant.library.dir : C:\ToolBox\apps\dumps\Eclipse3.7\plugins\org.apache.ant_1.8.2.v20120109-1030\lib
java.vm.vendor : Sun Microsystems Inc.
java.vendor.url : http://java.sun.com/
path.separator : ;
java.vm.name : Java HotSpot(TM) 64-Bit Server VM
file.encoding.pkg : sun.io
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:\ToolBox\work\ClearCase\oo018c_toolbox_test_data\vobs\toolbox_test_data\Projects\TestFixtures\scripts
java.runtime.version : 1.6.0_37-b06
java.awt.graphicsenv : sun.awt.Win32GraphicsEnvironment
java.endorsed.dirs : C:\Program Files\Java\jdk1.6.0_37\jre\lib\endorsed
os.arch : amd64
java.io.tmpdir : C:\Users\oo018c\AppData\Local\Temp\
line.separator : 
java.vm.specification.vendor : Sun Microsystems Inc.
user.variant : 
os.name : Windows 7
ant.home : C:\ToolBox\apps\dumps\Eclipse3.7\plugins\org.apache.ant_1.8.2.v20120109-1030
sun.jnu.encoding : Cp1252
java.library.path : C:\Windows\system32;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\oracle\11gR2client64bit\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Gemalto\Classic Client\BIN;C:\Program Files (x86)\Gemalto\Classic Client\BIN;C:\Program Files (x86)\Common Files\ACD Systems\EN;C:\Program Files (x86)\Common Files\ACD Systems;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files\Adobe\Adobe PDF iFilter 9 for 64-bit platforms\bin\;C:\Program Files (x86)\IBM\RationalSDLC\ClearCase\bin;C:\Program Files (x86)\IBM\RationalSDLC\common;C:\oracle\11gR2client32bit\bin\;C:\Program Files\Java\jdk1.6.0_37\bin;C:\Program Files (x86)\Git\cmd;C:\Program Files (x86)\Git\bin;C:\ToolBox\apps\dumps\mongodb-2.0.4\bin;C:\ToolBox\apps\dumps\scala-2.9.2\bin;C:\ToolBox\apps\dumps\Ant1.8.3\bin;C:\ToolBox\apps\dumps\apache-maven-3.0.4\bin;C:\ToolBox\apps\dumps\ccrccli_8.0.0.2;C:\ToolBox\apps\dumps\apache-tomcat-6.0.20\bin;C:\ToolBox\apps\dumps\Eclipse-TPTP-AgentControllerWinEM64T-4.7.2\plugins\org.eclipse.tptp.javaprofiler;C:\ToolBox\apps\dumps\Eclipse-TPTP-AgentControllerWinEM64T-4.7.2\bin;c:\cygwin\bin;c:\cygwin\usr\bin;.;C:\ToolBox\apps\dumps\Eclipse3.7\configuration\org.eclipse.osgi\bundles\778\1\.cp
java.specification.name : Java Platform API Specification
java.class.version : 50.0
sun.management.compiler : HotSpot 64-Bit Tiered Compilers
os.version : 6.1
user.home : C:\Users\oo018c
user.timezone : America/Los_Angeles
java.awt.printerjob : sun.awt.windows.WPrinterJob
file.encoding : UTF-8
java.specification.version : 1.6
user.name : oo018c
java.class.path : C:\ToolBox\apps\dumps\Eclipse3.7\plugins\org.apache.ant_1.8.2.v20120109-1030\lib\ant-antlr.jar;C:\ToolBox\apps\dumps\Eclipse3.7\plugins\org.apache.ant_1.8.2.v20120109-1030\lib\ant-apache-bcel.jar;C:\ToolBox\apps\dumps\Eclipse3.7\plugins\org.apache.ant_1.8.2.v20120109-1030\lib\ant-apache-bsf.jar;C:\ToolBox\apps\dumps\Eclipse3.7\plugins\org.apache.ant_1.8.2.v20120109-1030\lib\ant-apache-log4j.jar;C:\ToolBox\apps\dumps\Eclipse3.7\plugins\org.apache.ant_1.8.2.v20120109-1030\lib\ant-apache-oro.jar;C:\ToolBox\apps\dumps\Eclipse3.7\plugins\org.apache.ant_1.8.2.v20120109-1030\lib\ant-apache-regexp.jar;C:\ToolBox\apps\dumps\Eclipse3.7\plugins\org.apache.ant_1.8.2.v20120109-1030\lib\ant-apache-resolver.jar;C:\ToolBox\apps\dumps\Eclipse3.7\plugins\org.apache.ant_1.8.2.v20120109-1030\lib\ant-apache-xalan2.jar;C:\ToolBox\apps\dumps\Eclipse3.7\plugins\org.apache.ant_1.8.2.v20120109-1030\lib\ant-commons-logging.jar;C:\ToolBox\apps\dumps\Eclipse3.7\plugins\org.apache.ant_1.8.2.v20120109-1030\lib\ant-commons-net.jar;C:\ToolBox\apps\dumps\Eclipse3.7\plugins\org.apache.ant_1.8.2.v20120109-1030\lib\ant-jai.jar;C:\ToolBox\apps\dumps\Eclipse3.7\plugins\org.apache.ant_1.8.2.v20120109-1030\lib\ant-javamail.jar;C:\ToolBox\apps\dumps\Eclipse3.7\plugins\org.apache.ant_1.8.2.v20120109-1030\lib\ant-jdepend.jar;C:\ToolBox\apps\dumps\Eclipse3.7\plugins\org.apache.ant_1.8.2.v20120109-1030\lib\ant-jmf.jar;C:\ToolBox\apps\dumps\Eclipse3.7\plugins\org.apache.ant_1.8.2.v20120109-1030\lib\ant-jsch.jar;C:\ToolBox\apps\dumps\Eclipse3.7\plugins\org.apache.ant_1.8.2.v20120109-1030\lib\ant-junit.jar;C:\ToolBox\apps\dumps\Eclipse3.7\plugins\org.apache.ant_1.8.2.v20120109-1030\lib\ant-junit4.jar;C:\ToolBox\apps\dumps\Eclipse3.7\plugins\org.apache.ant_1.8.2.v20120109-1030\lib\ant-launcher.jar;C:\ToolBox\apps\dumps\Eclipse3.7\plugins\org.apache.ant_1.8.2.v20120109-1030\lib\ant-netrexx.jar;C:\ToolBox\apps\dumps\Eclipse3.7\plugins\org.apache.ant_1.8.2.v20120109-1030\lib\ant-swing.jar;C:\ToolBox\apps\dumps\Eclipse3.7\plugins\org.apache.ant_1.8.2.v20120109-1030\lib\ant-testutil.jar;C:\ToolBox\apps\dumps\Eclipse3.7\plugins\org.apache.ant_1.8.2.v20120109-1030\lib\ant.jar;C:\ToolBox\apps\dumps\Eclipse3.7\configuration\org.eclipse.osgi\bundles\182\1\.cp\lib\antdebug.jar;C:\ToolBox\apps\dumps\Eclipse3.7\configuration\org.eclipse.osgi\bundles\182\1\.cp\lib\remote.jar;C:\ToolBox\apps\dumps\Eclipse3.7\configuration\org.eclipse.osgi\bundles\183\1\.cp\lib\remoteAnt.jar;C:\Program Files\Java\jdk1.6.0_37\lib\tools.jar;C:\ToolBox\apps\dumps\Eclipse3.7\plugins\org.eclipse.swt.win32.win32.x86_64_3.7.2.v3740f.jar
java.vm.specification.version : 1.0
sun.arch.data.model : 64
java.home : C:\Program Files\Java\jdk1.6.0_37\jre
sun.java.command : org.eclipse.ant.internal.launching.remote.InternalAntRunner -diagnostics -Dorg.eclipse.ant.core.ANT_PROCESS_ID=1364337380010 -Declipse.connect.port=51250 -Declipse.pdebuild.home=/C:/ToolBox/apps/dumps/Eclipse3.7/plugins/org.eclipse.pde.build_3.7.0.v20111116-2009/./ -Declipse.pdebuild.scripts=/C:/ToolBox/apps/dumps/Eclipse3.7/plugins/org.eclipse.pde.build_3.7.0.v20111116-2009/scripts/ -Declipse.pdebuild.templates=/C:/ToolBox/apps/dumps/Eclipse3.7/plugins/org.eclipse.pde.build_3.7.0.v20111116-2009/templates/ -Dant.home=C:\ToolBox\apps\dumps\Eclipse3.7\plugins\org.apache.ant_1.8.2.v20120109-1030 -logger org.eclipse.ant.internal.launching.remote.logger.RemoteAntBuildLogger -inputhandler org.eclipse.ant.internal.ui.antsupport.inputhandler.ProxyInputHandler -buildfile C:\ToolBox\work\ClearCase\oo018c_toolbox_test_data\vobs\toolbox_test_data\Projects\TestFixtures\scripts\build.xml CC.compile
java.specification.vendor : Sun Microsystems Inc.
user.language : en
awt.toolkit : sun.awt.windows.WToolkit
java.vm.info : mixed mode
java.version : 1.6.0_37
java.ext.dirs : C:\Program Files\Java\jdk1.6.0_37\jre\lib\ext;C:\Windows\Sun\Java\lib\ext
sun.boot.class.path : C:\Program Files\Java\jdk1.6.0_37\jre\lib\resources.jar;C:\Program Files\Java\jdk1.6.0_37\jre\lib\rt.jar;C:\Program Files\Java\jdk1.6.0_37\jre\lib\sunrsasign.jar;C:\Program Files\Java\jdk1.6.0_37\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.6.0_37\jre\lib\jce.jar;C:\Program Files\Java\jdk1.6.0_37\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.6.0_37\jre\lib\modules\jdk.boot.jar;C:\Program Files\Java\jdk1.6.0_37\jre\classes
java.vendor : Sun Microsystems Inc.
file.separator : \
java.vendor.url.bug : http://java.sun.com/cgi-bin/bugreport.cgi
sun.cpu.endian : little
sun.io.unicode.encoding : UnicodeLittle
sun.desktop : windows
sun.cpu.isalist : amd64
-------------------------------------------
 Temp dir
-------------------------------------------
Temp dir is C:\Users\oo018c\AppData\Local\Temp\
Temp dir is writeable
Temp dir alignment with system clock is 33 ms
-------------------------------------------
 Locale information
-------------------------------------------
Timezone Pacific Standard Time offset=-25200000
-------------------------------------------
 Proxy information
-------------------------------------------
Java1.5+ proxy settings:
Direct connection
Total time: 1 second
4

1 回答 1

0

Can you try adding your J2SE - jdk/bin directory path to system 'path' variable. Go to 'my computer' -> right click -> properties -> advanced -> environment variables -> system variables -> path and append a semicolon followed by your jdk bin path. Or else make sure ant.bat is setting the correct java home to a jdk.

Can you double check to make sure your 'JAVA_HOME' is set to "C:\Program Files\Java\jdk1.6.0_37".

Go to 'my computer' -> right click -> properties -> advanced -> environment variables -> system variables -> (If JAVA_HOME is not already there then 'new' else pick JAVA_HOME) and set the value to 'C:\Program Files\Java\jdk1.6.0_37'(no quotes).

Now close and start a fresh console and try running your ant script.

Alternatively you could just fire the following in the console before starting your ant script:

set JAVA_HOME=C:\Progra~1\Java\jdk1.6.0_37

于 2013-03-26T20:52:17.237 回答