Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > JDOM: java.lang.NoClassDefFoundError: org/jdom/Content

Reply
Thread Tools

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

 
 
Bernd Oninger
Guest
Posts: n/a
 
      06-09-2004
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
 
Reply With Quote
 
 
 
 
GIMME
Guest
Posts: n/a
 
      06-10-2004
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.
 
Reply With Quote
 
 
 
 
Richard
Guest
Posts: n/a
 
      06-21-2004
http://www.velocityreviews.com/forums/(E-Mail Removed) (GIMME) wrote in message news:<(E-Mail Removed). 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
 
Reply With Quote
 
GIMME
Guest
Posts: n/a
 
      06-21-2004
> 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




Advertisments