一定是配置不对。看看你启动Tomcat的命令中是否指定了Jdom的Jar。

解决方案 »

  1.   

    启动的文件是startup.bat,不知道改哪个地方,请指教。
    其实我是想试试这个程序,因为我想对xml进行操作
    package xml;
     import org.jdom.*;
    import org.jdom.output.*;
    import org.jdom.input.*; 
    import java.io.*; public class readXML {  private Document doc=null;  public readXML(){}   public String readXML(String xmlFileName){    String strExc="";    try{
           SAXBuilder sb = new SAXBuilder(); 
           doc = sb.build(new FileInputStream(xmlFileName));
          }catch(Exception e){
           strExc=e.toString();
        }
        return(strExc);
     }  public Document getXmlDoc(){
        return(doc);
     }
    }
      

  2.   

    下面是startup.bat的文件,修改哪里?
    @echo off
    if "%OS%" == "Windows_NT" setlocal
    rem ---------------------------------------------------------------------------
    rem Stop script for the CATALINA Server
    rem
    rem $Id: shutdown.bat,v 1.4.4.2 2002/01/30 18:10:40 patrickl Exp $
    rem ---------------------------------------------------------------------------rem Guess CATALINA_HOME if not defined
    if not "%CATALINA_HOME%" == "" goto gotHome
    set CATALINA_HOME=.
    if exist "%CATALINA_HOME%\bin\catalina.bat" goto okHome
    set CATALINA_HOME=..
    :gotHome
    if exist "%CATALINA_HOME%\bin\catalina.bat" goto okHome
    echo The CATALINA_HOME environment variable is not defined correctly
    echo This environment variable is needed to run this program
    goto end
    :okHomeset EXECUTABLE=%CATALINA_HOME%\bin\catalina.batrem Check that target executable exists
    if exist "%EXECUTABLE%" goto okExec
    echo Cannot find %EXECUTABLE%
    echo This file is needed to run this program
    goto end
    :okExecrem Get remaining unshifted command line arguments and save them in the
    set CMD_LINE_ARGS=
    :setArgs
    if ""%1""=="""" goto doneSetArgs
    set CMD_LINE_ARGS=%CMD_LINE_ARGS% %1
    shift
    goto setArgs
    :doneSetArgscall "%EXECUTABLE%" stop %CMD_LINE_ARGS%:end
      

  3.   

    readXML.java:4: package org.jdom does not exist!!!
    这是编译时候的问题,和tomcat的运行还没有关系,将引用的类路径设置到IDE的环境中,不知道你用的IDE,不好说具体的方法,最简单如下javac -classpath "jdom.jar的路径" "源代码的路径"。
    你的试验代码不用Tomcat。
      

  4.   

    我用的是editplus
    javac配置:
    $(FileName) -deprecation -classpath "E:\ApacheTomcat4\lib" $(FileDir)
    结果提示
    ---------- javac ----------
    javac: invalid flag: I:\wf\MYstudy\javastudy\jsp\myjsp\WEB-INF\classes\xml
    Usage: javac <options> <source files>
    where possible options include:
      -g                        Generate all debugging info
      -g:none                   Generate no debugging info
      -g:{lines,vars,source}    Generate only some debugging info
      -nowarn                   Generate no warnings
      -verbose                  Output messages about what the compiler is doing
      -deprecation              Output source locations where deprecated APIs are used
      -classpath <path>         Specify where to find user class files
      -sourcepath <path>        Specify where to find input source files
      -bootclasspath <path>     Override location of bootstrap class files
      -extdirs <dirs>           Override location of installed extensions
      -d <directory>            Specify where to place generated class files
      -encoding <encoding>      Specify character encoding used by source files
      -source <release>         Provide source compatibility with specified release
      -target <release>         Generate class files for specific VM version
      -help                     Print a synopsis of standard options
    输出完成 (耗时 3 秒) - 正常终止