[jdom-interest] Request for help: getting started ...

Bob Tykulsker surftool at pacbell.net
Wed Aug 15 15:31:45 PDT 2001


Hello World,

I am having trouble building the PrettyPrinter class documented in
http://www.javaworld.com/javaworld/jw-05-2000/jw-0518-jdom-2.html

1) I downloaded and installed jdk1.3.1 and jdom-b7

2) I set my CLASSPATH as follows:
% echo $CLASSPATH
.:/home/bobt/apps/jdom-b7/lib:/home/bobt/apps/jdom-b7/build:/home/bobt/apps/
jdom-b7/build/classes:/home/bobt/apps/jdk1.3.1/lib

3) I create the file PrettyPrinter.java as follows
[bobt at gw boggle]$ cat PrettyPrinter.java
import java.io.*;
import org.jdom.*;
import org.jdom.input.*;
import org.jdom.output.*;

public class PrettyPrinter {
   public static void main(String[] args) {
        // Assume filename argument
        String filename = args[0];

        try {
            // Build the document with SAX and Xerces, no validation
            SAXBuilder builder = new SAXBuilder();
            // Create the document
            Document doc = builder.build(new File(filename));

            // Output the document, use standard formatter
            XMLOutputter fmt = new XMLOutputter();
            fmt.output(doc, System.out);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

4) when I try to compile, I get the following error message:
% javac PrettyPrinter.java
PrettyPrinter.java:15: cannot access org.xml.sax.InputSource
file org/xml/sax/InputSource.class not found
            Document doc = builder.build(new File(filename));
                                  ^
1 error

Any clue as to what I am doing wrong?

Thanks in advance,

BobT




More information about the jdom-interest mailing list