Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / June 2004

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Bernd Oninger - 09 Jun 2004 15:22 GMT
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
GIMME - 10 Jun 2004 19:47 GMT
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.
Richard - 21 Jun 2004 14:42 GMT
> org.jdom.Content is in jdom.jar.
>
[quoted text clipped - 3 lines]
> 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
GIMME - 21 Jun 2004 22:08 GMT
> 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"
[quoted text clipped - 3 lines]
>
> ...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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.