JDOM: java.lang.NoClassDefFoundError: org/jdom/Content

Discussion in 'XML' started by Bernd Oninger, Jun 9, 2004.

  1. When I run the successfully compiled java source shown at the end I got a runtime error:

    Exception in thread "main" java.lang.NoClassDefFoundError: org/jdom/Content

    Where is the missing class ?

    I copied the newest jdom.jar from newest JDOM release b10 to the folder

    jdk\jre\lib\endorsed

    Is this not enough ?

    Bernd
     
    Bernd Oninger, Jun 9, 2004
    #1
    1. Advertising

  2. Bernd Oninger

    GIMME Guest

    org.jdom.Content is in jdom.jar.

    Note that this class does not exist in some previous versions of jdom.jar
    (for example the version which comes with b8 which I just checked).

    Personally, I wouldn't store jdom.jar in jdk\jre\lib\endorsed. Make
    certain your CLASSPATH is pointing to a valid jdom.jar file.
     
    GIMME, Jun 10, 2004
    #2
    1. Advertising

  3. Bernd Oninger

    Richard Guest

    (GIMME) wrote in message news:<>...
    > org.jdom.Content is in jdom.jar.
    >
    > Note that this class does not exist in some previous versions of jdom.jar
    > (for example the version which comes with b8 which I just checked).
    >
    > Personally, I wouldn't store jdom.jar in jdk\jre\lib\endorsed. Make
    > certain your CLASSPATH is pointing to a valid jdom.jar file.


    Hello!

    I have the same problem as Bernd Oninger, I can compile but not run
    the program.

    Im trying to make this simple example to work...

    ---- example1.java ----
    import org.jdom.*;

    public class example1
    {
    public static void main(String[] args)
    {
    Element root = new Element("myRootElement");
    Document doc = new Document(root);
    root.setText("This is a root element");
    System.out.println(doc);
    }
    }
    -----------------------

    To compile I use this:
    >javac example1.java -classpath "jdom.jar"


    ....it works great since i have the jdom.jar-file in the same directory
    (I asume that you can have the jar-file anywhere you want, as long as
    the path is correct).

    But when I run the program I get this:
    >java example1 -classpath "jdom.jar"

    Exception in thread "main" java.lang.NoClassDefFoundError:
    org/jdom/Element
    at example1.main(example1.java:7)

    ....why wont this work???

    GIMME, when you are talking about the CLASSPATH do you mean the
    enviroment variable (NOTE: Im using windows here, not linux)??? I have
    tryed "set CLASSPATH ..." but its still the same problem.


    THX in advance
    /Richard
     
    Richard, Jun 21, 2004
    #3
  4. Bernd Oninger

    GIMME Guest

    > To compile I use this:
    > >javac example1.java -classpath "jdom.jar"

    >
    > ...it works great since i have the jdom.jar-file in the same directory
    > (I asume that you can have the jar-file anywhere you want, as long as
    > the path is correct).


    Good. Right.

    >
    > But when I run the program I get this:
    > >java example1 -classpath "jdom.jar"

    > Exception in thread "main" java.lang.NoClassDefFoundError:
    > org/jdom/Element
    > at example1.main(example1.java:7)
    >
    > ...why wont this work???
    >


    You have to have the classpath stuff up front ...

    java -classpath $CLASSPATH example1

    > GIMME, when you are talking about the CLASSPATH do you mean the
    > enviroment variable (NOTE: Im using windows here, not linux)???


    Yes. Although the syntax of separaters differ, back slashes instead
    of forward slashes, in each instance you want an environment variable.

    I have
    > tryed "set CLASSPATH ..." but its still the same problem.



    Try :

    echo %CLASSPATH%


    Relying on Window's environmental variables all the time can
    lead to some undesirable behavior.

    I use a dos batch script to set up my environmental variables
    and then call cygwin. Here a sample script for you to study.
    If you don't have cygwin installed delete or comment out the last
    line.

    @echo off

    set PROOT=C:\Project\WEBELocal\Vignette\Portal
    set JAVA_HOME=C:\Apps\jdk1.3.1_07

    set JARS=C:\Project\WEBELocal\Vignette\Portal\portal\WEB-INF\lib
    set CLASSES=C:\Project\WEBELocal\Vignette\Portal\portal\WEB-INF\classes

    set CLASSPATH=.
    set CLASSPATH=%CLASSPATH%;C:\bin
    set CLASSPATH=%CLASSPATH%;%CLASSES%
    set CLASSPATH=%CLASSPATH%;%JARS%\epicentric.jar
    set CLASSPATH=%CLASSPATH%;%JARS%\bsf.jar
    set CLASSPATH=%CLASSPATH%;%JARS%\bsfengines.jar
    set CLASSPATH=%CLASSPATH%;%JARS%\collections.jar
    set CLASSPATH=%CLASSPATH%;%JARS%\cos.jar

    set ANT_HOME=%PROOT%\samples\cartool\jakarta-ant-1.5

    C:\WINDOWS\system32\COMMAND.COM /E:4096 /c C:\cygwin\cygwin.bat
     
    GIMME, Jun 21, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Wendy S
    Replies:
    1
    Views:
    6,406
    Darren Davison
    Aug 5, 2003
  2. Bernd Oninger
    Replies:
    4
    Views:
    12,440
    GIMME
    Jun 21, 2004
  3. Maneesh
    Replies:
    2
    Views:
    10,716
  4. Tinker
    Replies:
    4
    Views:
    5,368
    Harry Bosch
    Oct 9, 2005
  5. Replies:
    1
    Views:
    2,182
    Irmen de Jong
    Jun 22, 2004
Loading...

Share This Page