File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes XML and Related Technologies and the fly likes NoClassDefFoundError with JDOM Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "NoClassDefFoundError with JDOM" Watch "NoClassDefFoundError with JDOM" New topic

NoClassDefFoundError with JDOM

Michael Krause

Joined: Jul 13, 2001
Posts: 2
I copied the following listing from the book "Java and XML":
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder;
public class SAXTest {

public static void main(String[] args) {
if (args.length != 1) {
System.out.println("Start: SAXTest [Filename]");

try {
SAXBuilder builder = new SAXBuilder(false);
Document doc = File(args[0]));
System.out.println("File read correctly");
} catch (JDOMException e) {
}//end of catch
}//end of main
}//end of class
The JDom-jar File is in \jdk1.3.1\jre\lib\ext just like the File xerces.jar.
Compiling gives me no error but as I start the program with
java saxtest file.xml
it gives me a
java.lang.NoClassDefFoundError: org/jdom/JDOMException.
Can anybody tell me, what causes this error?
thanx in advance
Vladan Radovanovic
Ranch Hand

Joined: Mar 20, 2000
Posts: 216
Can you tell us what your classpath settings are?
Michael Krause

Joined: Jul 13, 2001
Posts: 2
Of course, here they are including PATH and JAVA_HOME:
SET PATH=%PATH%;D:\Programme\Programming\jdk1.3.1\bin;D:\Programme\Programming\jdk1.3.1\xerces-1_4_1;D:\Programme\Programming\jdk1.3.1\jdom-b7\build
SET CLASSPATH=D:\Programme\Programming\jdk1.3.1\bin;D:\Programme\Programming\jdk1.3.1\lib;D:\Programme\Programming\jdk1.3.1\xerces-1_4_1\xerces.jar;D:\Programme\Programming\jdk1.3.1\jd om-b7\build\jdom.rar
SET JAVA_HOME=D:\Programme\Programming\jdk1.3.1
Vladan Radovanovic
Ranch Hand

Joined: Mar 20, 2000
Posts: 216
What happens if you change that jdom.rar into jdom.jar? That is at the end of your classpath setting.
And why do we have space between jd and om-b7? Again, the classpath for jdom.
[This message has been edited by Vladan Radovanovic (edited July 25, 2001).]
I agree. Here's the link:
subject: NoClassDefFoundError with JDOM