运行ant目标时的java.lang.NoClassDefFoundError

时间:2013-03-26 20:45:46

标签: ant

我有一个具有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

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

我还验证了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

1 个答案:

答案 0 :(得分:0)

您可以尝试将J2SE - jdk / bin目录路径添加到系统'path'变量中。转到“我的电脑” - >右键单击 - >属性 - >高级 - >环境变量 - >系统变量 - >路径并附加一个分号后跟你的jdk bin路径。或者确保ant.bat将正确的java home设置为jdk。

您可以仔细检查以确保'JAVA_HOME'设置为“C:\ Program Files \ Java \ jdk1.6.0_37”。

转到“我的电脑” - >右键单击 - >属性 - >高级 - >环境变量 - >系统变量 - > (如果JAVA_HOME还没有,那么'new'或者选择JAVA_HOME)并将值设置为'C:\ Program Files \ Java \ jdk1.6.0_37'(没有引号)。

现在关闭并启动一个全新的控制台并尝试运行你的蚂蚁脚本。

或者,您可以在启动ant脚本之前在控制台中触发以下内容:

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