java.lang. noclassdeffoundererror在运行一个目标



我有一个具有java编译目标的ant构建文件。相同的eclipse发行版运行良好,并成功运行其他ant构建文件。在这个特殊的工作空间里;当我运行ant目标时,它会失败,并出现以下错误:

    [javac] C:MyProjectscriptsbuild.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:MyProjectbuild
    [javac] Compiling 9 source files to C:MyProjectbuild
    [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:ToolBoxappsdumpsEclipse3.7pluginsorg.apache.ant_1.8.2.v20120109-1030libant.jar
ant.home: C:ToolBoxappsdumpsEclipse3.7pluginsorg.apache.ant_1.8.2.v20120109-1030
-------------------------------------------
 ANT_HOME/lib jar listing
-------------------------------------------
ant.home: C:ToolBoxappsdumpsEclipse3.7pluginsorg.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:Usersoo018c
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 FilesJavajdk1.6.0_37jrebin
java.vm.version : 20.12-b01
ant.library.dir : C:ToolBoxappsdumpsEclipse3.7pluginsorg.apache.ant_1.8.2.v20120109-1030lib
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:ToolBoxworkClearCaseoo018c_toolbox_test_datavobstoolbox_test_dataProjectsTestFixturesscripts
java.runtime.version : 1.6.0_37-b06
java.awt.graphicsenv : sun.awt.Win32GraphicsEnvironment
java.endorsed.dirs : C:Program FilesJavajdk1.6.0_37jrelibendorsed
os.arch : amd64
java.io.tmpdir : C:Usersoo018cAppDataLocalTemp
line.separator : 
java.vm.specification.vendor : Sun Microsystems Inc.
user.variant : 
os.name : Windows 7
ant.home : C:ToolBoxappsdumpsEclipse3.7pluginsorg.apache.ant_1.8.2.v20120109-1030
sun.jnu.encoding : Cp1252
java.library.path : C:Windowssystem32;C:WindowsSunJavabin;C:Windowssystem32;C:Windows;C:oracle11gR2client64bitbin;C:Windowssystem32;C:Windows;C:WindowsSystem32Wbem;C:WindowsSystem32WindowsPowerShellv1.0;C:Program FilesGemaltoClassic ClientBIN;C:Program Files (x86)GemaltoClassic ClientBIN;C:Program Files (x86)Common FilesACD SystemsEN;C:Program Files (x86)Common FilesACD Systems;C:Program FilesIntelWiFibin;C:Program FilesCommon FilesIntelWirelessCommon;C:Program FilesAdobeAdobe PDF iFilter 9 for 64-bit platformsbin;C:Program Files (x86)IBMRationalSDLCClearCasebin;C:Program Files (x86)IBMRationalSDLCcommon;C:oracle11gR2client32bitbin;C:Program FilesJavajdk1.6.0_37bin;C:Program Files (x86)Gitcmd;C:Program Files (x86)Gitbin;C:ToolBoxappsdumpsmongodb-2.0.4bin;C:ToolBoxappsdumpsscala-2.9.2bin;C:ToolBoxappsdumpsAnt1.8.3bin;C:ToolBoxappsdumpsapache-maven-3.0.4bin;C:ToolBoxappsdumpsccrccli_8.0.0.2;C:ToolBoxappsdumpsapache-tomcat-6.0.20bin;C:ToolBoxappsdumpsEclipse-TPTP-AgentControllerWinEM64T-4.7.2pluginsorg.eclipse.tptp.javaprofiler;C:ToolBoxappsdumpsEclipse-TPTP-AgentControllerWinEM64T-4.7.2bin;c:cygwinbin;c:cygwinusrbin;.;C:ToolBoxappsdumpsEclipse3.7configurationorg.eclipse.osgibundles7781.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:Usersoo018c
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:ToolBoxappsdumpsEclipse3.7pluginsorg.apache.ant_1.8.2.v20120109-1030libant-antlr.jar;C:ToolBoxappsdumpsEclipse3.7pluginsorg.apache.ant_1.8.2.v20120109-1030libant-apache-bcel.jar;C:ToolBoxappsdumpsEclipse3.7pluginsorg.apache.ant_1.8.2.v20120109-1030libant-apache-bsf.jar;C:ToolBoxappsdumpsEclipse3.7pluginsorg.apache.ant_1.8.2.v20120109-1030libant-apache-log4j.jar;C:ToolBoxappsdumpsEclipse3.7pluginsorg.apache.ant_1.8.2.v20120109-1030libant-apache-oro.jar;C:ToolBoxappsdumpsEclipse3.7pluginsorg.apache.ant_1.8.2.v20120109-1030libant-apache-regexp.jar;C:ToolBoxappsdumpsEclipse3.7pluginsorg.apache.ant_1.8.2.v20120109-1030libant-apache-resolver.jar;C:ToolBoxappsdumpsEclipse3.7pluginsorg.apache.ant_1.8.2.v20120109-1030libant-apache-xalan2.jar;C:ToolBoxappsdumpsEclipse3.7pluginsorg.apache.ant_1.8.2.v20120109-1030libant-commons-logging.jar;C:ToolBoxappsdumpsEclipse3.7pluginsorg.apache.ant_1.8.2.v20120109-1030libant-commons-net.jar;C:ToolBoxappsdumpsEclipse3.7pluginsorg.apache.ant_1.8.2.v20120109-1030libant-jai.jar;C:ToolBoxappsdumpsEclipse3.7pluginsorg.apache.ant_1.8.2.v20120109-1030libant-javamail.jar;C:ToolBoxappsdumpsEclipse3.7pluginsorg.apache.ant_1.8.2.v20120109-1030libant-jdepend.jar;C:ToolBoxappsdumpsEclipse3.7pluginsorg.apache.ant_1.8.2.v20120109-1030libant-jmf.jar;C:ToolBoxappsdumpsEclipse3.7pluginsorg.apache.ant_1.8.2.v20120109-1030libant-jsch.jar;C:ToolBoxappsdumpsEclipse3.7pluginsorg.apache.ant_1.8.2.v20120109-1030libant-junit.jar;C:ToolBoxappsdumpsEclipse3.7pluginsorg.apache.ant_1.8.2.v20120109-1030libant-junit4.jar;C:ToolBoxappsdumpsEclipse3.7pluginsorg.apache.ant_1.8.2.v20120109-1030libant-launcher.jar;C:ToolBoxappsdumpsEclipse3.7pluginsorg.apache.ant_1.8.2.v20120109-1030libant-netrexx.jar;C:ToolBoxappsdumpsEclipse3.7pluginsorg.apache.ant_1.8.2.v20120109-1030libant-swing.jar;C:ToolBoxappsdumpsEclipse3.7pluginsorg.apache.ant_1.8.2.v20120109-1030libant-testutil.jar;C:ToolBoxappsdumpsEclipse3.7pluginsorg.apache.ant_1.8.2.v20120109-1030libant.jar;C:ToolBoxappsdumpsEclipse3.7configurationorg.eclipse.osgibundles1821.cplibantdebug.jar;C:ToolBoxappsdumpsEclipse3.7configurationorg.eclipse.osgibundles1821.cplibremote.jar;C:ToolBoxappsdumpsEclipse3.7configurationorg.eclipse.osgibundles1831.cplibremoteAnt.jar;C:Program FilesJavajdk1.6.0_37libtools.jar;C:ToolBoxappsdumpsEclipse3.7pluginsorg.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 FilesJavajdk1.6.0_37jre
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:ToolBoxappsdumpsEclipse3.7pluginsorg.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:ToolBoxworkClearCaseoo018c_toolbox_test_datavobstoolbox_test_dataProjectsTestFixturesscriptsbuild.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 FilesJavajdk1.6.0_37jrelibext;C:WindowsSunJavalibext
sun.boot.class.path : C:Program FilesJavajdk1.6.0_37jrelibresources.jar;C:Program FilesJavajdk1.6.0_37jrelibrt.jar;C:Program FilesJavajdk1.6.0_37jrelibsunrsasign.jar;C:Program FilesJavajdk1.6.0_37jrelibjsse.jar;C:Program FilesJavajdk1.6.0_37jrelibjce.jar;C:Program FilesJavajdk1.6.0_37jrelibcharsets.jar;C:Program FilesJavajdk1.6.0_37jrelibmodulesjdk.boot.jar;C:Program FilesJavajdk1.6.0_37jreclasses
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:Usersoo018cAppDataLocalTemp
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

您可以尝试将J2SE - jdk/bin目录路径添加到系统'path'变量中吗?转到"我的电脑"->右键单击->属性->高级->环境变量->系统变量->路径,在jdk bin路径后面添加分号。否则,请确保ant.bat将正确的java home设置为jdk。

你能再检查一下你的"JAVA_HOME"是否设置为"C:Program FilesJavajdk1.6.0_37"吗?

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

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

或者,您可以在启动ant脚本之前在控制台中执行以下命令:

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

相关内容

  • 没有找到相关文章

最新更新