Hi Guys,

I am trying to follow an example using JDOM, which will write, update and delete the contents of an XML file.

I thought I had set the JDOM & Xerces classpaths correctly, but I'm guessing not now:

I had one error in my java file as follows:

C:\Tomcat 5.5\webapps\ROOT\XMLEdit>javac CATALOGManager.java
CATALOGManager.java:81: illegal escape character
FileWriter f = new FileWriter(new File("C:\\Tomcat 5.5\\webapps\\ROOT\\X
MLEdit\CATALOG1.xml"));
^
1 error

So I forgot the extra '\' in the path. Not a problem.

When I then went onto compile the java file thinking all was ok, I got the following errors:

C:\Tomcat 5.5\webapps\ROOT\XMLEdit>javac CATALOGManager.java
CATALOGManager.java:3: package org.jdom does not exist
import org.jdom.*;
^
CATALOGManager.java:4: package org.jdom.output does not exist
import org.jdom.output.XMLOutputter;
^
CATALOGManager.java:6: package org.jdom.input does not exist
import org.jdom.input.*;
^
CATALOGManager.java:7: package org.jdom.output does not exist
import org.jdom.output.*;
^
CATALOGManager.java:12: cannot find symbol
symbol : class Document
location: class XMLEdit.CATALOGManager
Document docs;
^
CATALOGManager.java:18: cannot find symbol
symbol : class SAXBuilder
location: class XMLEdit.CATALOGManager
SAXBuilder builder = new SAXBuilder();
^
CATALOGManager.java:18: cannot find symbol
symbol : class SAXBuilder
location: class XMLEdit.CATALOGManager
SAXBuilder builder = new SAXBuilder();
^
CATALOGManager.java:19: cannot find symbol
symbol : variable doc
location: class XMLEdit.CATALOGManager
doc = builder.build(filename);
^
CATALOGManager.java:20: cannot find symbol
symbol : variable doc
location: class XMLEdit.CATALOGManager
product = doc.getRootElement().getChildren();
^
CATALOGManager.java:21: cannot find symbol
symbol : class JDOMException
location: class XMLEdit.CATALOGManager
} catch (JDOMException e) {
^
CATALOGManager.java:36: cannot find symbol
symbol : class Element
location: class XMLEdit.CATALOGManager
Element product = (Element)product.get(index);
^
CATALOGManager.java:36: cannot find symbol
symbol : class Element
location: class XMLEdit.CATALOGManager
Element product = (Element)product.get(index);
^
CATALOGManager.java:41: cannot find symbol
symbol : class Element
location: class XMLEdit.CATALOGManager
Element product = (Element)product.get(index);
^
CATALOGManager.java:41: cannot find symbol
symbol : class Element
location: class XMLEdit.CATALOGManager
Element product = (Element)product.get(index);
^
CATALOGManager.java:47: cannot find symbol
symbol : class Element
location: class XMLEdit.CATALOGManager
Element product = (Element)product.get(index);
^
CATALOGManager.java:47: cannot find symbol
symbol : class Element
location: class XMLEdit.CATALOGManager
Element product = (Element)product.get(index);
^
CATALOGManager.java:53: cannot find symbol
symbol : class Element
location: class XMLEdit.CATALOGManager
Element product = (Element)product.get(index);
^
CATALOGManager.java:53: cannot find symbol
symbol : class Element
location: class XMLEdit.CATALOGManager
Element product = (Element)product.get(index);
^
CATALOGManager.java:60: cannot find symbol
symbol : variable products
location: class XMLEdit.CATALOGManager
products.remove(index);
^
CATALOGManager.java:64: cannot find symbol
symbol : class Element
location: class XMLEdit.CATALOGManager
Element product = new Element("product");
^
CATALOGManager.java:64: cannot find symbol
symbol : class Element
location: class XMLEdit.CATALOGManager
Element product = new Element("product");
^
CATALOGManager.java:65: cannot find symbol
symbol : class Attribute
location: class XMLEdit.CATALOGManager
product.setAttribute(new Attribute("id", id));
^
CATALOGManager.java:66: cannot find symbol
symbol : class Element
location: class XMLEdit.CATALOGManager
product.addContent(new Element("name").setText(name));
^
CATALOGManager.java:67: cannot find symbol
symbol : class Element
location: class XMLEdit.CATALOGManager
product.addContent(new Element("price").setText(price));
^
CATALOGManager.java:73: cannot find symbol
symbol : class Sortname
location: class XMLEdit.CATALOGManager
catalog.sort(product, new Sortname());
^
CATALOGManager.java:73: cannot find symbol
symbol : variable catalog
location: class XMLEdit.CATALOGManager
catalog.sort(product, new Sortname());
^
CATALOGManager.java:78: cannot find symbol
symbol : variable XMLOutputter
location: class XMLEdit.CATALOGManager
XMLOutputter.output(" ",true);
^
CATALOGManager.java:80: cannot find symbol
symbol : variable outputter
location: class XMLEdit.CATALOGManager
outputter.setTextNormalize(true);
^
CATALOGManager.java:81: cannot find symbol
symbol : class FileWriter
location: class XMLEdit.CATALOGManager
FileWriter f = new FileWriter(new File("C:\\Tomcat 5.5\\webapps\\ROOT\\X
MLEdit\\CATALOG1.xml"));
^
CATALOGManager.java:81: cannot find symbol
symbol : class FileWriter
location: class XMLEdit.CATALOGManager
FileWriter f = new FileWriter(new File("C:\\Tomcat 5.5\\webapps\\ROOT\\X
MLEdit\\CATALOG1.xml"));
^
CATALOGManager.java:81: cannot find symbol
symbol : class File
location: class XMLEdit.CATALOGManager
FileWriter f = new FileWriter(new File("C:\\Tomcat 5.5\\webapps\\ROOT\\X
MLEdit\\CATALOG1.xml"));
^
CATALOGManager.java:82: cannot find symbol
symbol : variable doc
location: class XMLEdit.CATALOGManager
outputter.output(doc, f);
^
CATALOGManager.java:82: cannot find symbol
symbol : variable outputter
location: class XMLEdit.CATALOGManager
outputter.output(doc, f);
^
CATALOGManager.java:104: cannot find symbol
symbol : method setIndex(int)
location: class XMLEdit.CATALOGManager
d.setIndex(i);
^
CATALOGManager.java:111: cannot find symbol
symbol : class XMLOutputter
location: class XMLEdit.CATALOGManager
XMLOutputter outputter = new XMLOutputter();
^
CATALOGManager.java:111: cannot find symbol
symbol : class XMLOutputter
location: class XMLEdit.CATALOGManager
XMLOutputter outputter = new XMLOutputter();
^
CATALOGManager.java:113: cannot find symbol
symbol : variable doc
location: class XMLEdit.CATALOGManager
outputter.output(doc, System.out);
^
37 errors

Which I cant understand. Could someone helpout setting the classpath for JDOM. As I have put the JDOM & Xerces jar files in my classpath and set the path as follows (using the environment variable in Windows):

C:\Program Files\Java\jdk1.5.0_02\bin;.;C:\Program Files\Java\jdk1.5.0_02\lib\jdom.jar; C:\Program Files\Java\jdk1.5.0_02\lib\xerces.jar"C:\Tomcat 5.5\common\lib\servlet-api.jar";"C:\Tomcat 5.5\common\lib\jsp-api.jar";"C:\Tomcat 5.5\common\lib\catalina-root.jar";"C:\Tomcat 5.5\common\lib\jdom.jar";"C:\Tomcat 5.5\common\lib\xerces.jar"

Is this incorrect? Is this what the errors are referring to?
Any Help much appreciated.
Reply With Quote