469,328 Members | 1,301 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,328 developers. It's quick & easy.

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

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
Jul 20 '05 #1
3 13614
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.
Jul 20 '05 #2
gi*******************@yahoo.com (GIMME) wrote in message news:<3f**************************@posting.google. com>...
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
Jul 20 '05 #3
> 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\W EB-INF\lib
set CLASSES=C:\Project\WEBELocal\Vignette\Portal\porta l\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
Jul 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

11 posts views Thread by Lem | last post: by
2 posts views Thread by Stefano Bianchi | last post: by
1 post views Thread by ptaz | last post: by
13 posts views Thread by Ash | last post: by
2 posts views Thread by zhengwt | last post: by
2 posts views Thread by sandhu236 | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.