|
-
JDOM Errors & How to set the classpath
Hi Guys,
I have been trying to setup and use JDOM I have tried every possible combinations I can think of with the class path. The classpath I have is as follows:
set CLASSPATH=.;C:\Program Files\Java\jdk1.5.0_02\bin;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\webapps\ROOT\WEB-INF\lib\jdom.jar;C:\Tomcat 5.5\webapps\ROOT\WEB-INF\lib\xerces.jar;C:\Tomcat 5.5\webapps\ROOT\XMLEdit;C:\Program Files\Java\jdk1.5.0_02\lib\tools.jar;
I do not know if this is completely incorrect for when using JDOM. So some pointers would be greatly appreciated please!
The errors I get when trying to compile the java file (that updates an xml file) is as follows:
C:\Tomcat 5.5\webapps\ROOT\XMLEdit>javac CATALOGMANAGER.java
CATALOGMANAGER.java:29: cannot find symbol
symbol : variable index
location: class XMLEdit.CATALOGManager
index = i;
^
CATALOGMANAGER.java:38: cannot find symbol
symbol : variable index
location: class XMLEdit.CATALOGManager
Element product = (Element)products.get(index);
^
CATALOGMANAGER.java:55: cannot find symbol
symbol : variable index
location: class XMLEdit.CATALOGManager
Element product = (Element)products.get(index);
^
CATALOGMANAGER.java:57: cannot find symbol
symbol : method setValue(java.lang.String)
location: class org.jdom.Element
product.getChild("name").setValue(name);
^
CATALOGMANAGER.java:58: cannot find symbol
symbol : method setValue(java.lang.String)
location: class org.jdom.Element
product.getChild("price").setValue(price);
^
CATALOGMANAGER.java:62: cannot find symbol
symbol : variable index
location: class XMLEdit.CATALOGManager
products.remove(index);
^
CATALOGMANAGER.java:70: cannot find symbol
symbol : method add(org.jdom.Element)
location: class org.jdom.Element
product.add(product);
^
CATALOGMANAGER.java:75: cannot find symbol
symbol : class Sortname
location: class XMLEdit.CATALOGManager
catalog.sort(products, new Sortname());
^
CATALOGMANAGER.java:75: cannot find symbol
symbol : variable catalog
location: class XMLEdit.CATALOGManager
catalog.sort(products, new Sortname());
^
CATALOGMANAGER.java:80: cannot find symbol
symbol : method output(java.lang.String,boolean)
location: class org.jdom.output.XMLOutputter
XMLOutputter.output(" ",true);
^
CATALOGMANAGER.java:82: cannot find symbol
symbol : variable outputter
location: class XMLEdit.CATALOGManager
outputter.setTextNormalize(true);
^
CATALOGMANAGER.java:83: cannot find symbol
symbol : class FileWriter
location: class XMLEdit.CATALOGManager
FileWriter f = new FileWriter(new File("C:\\Tomcat 5.5\\webapps\\ROOT\
MLEdit\\CATALOG1.xml"));
^
CATALOGMANAGER.java:83: cannot find symbol
symbol : class FileWriter
location: class XMLEdit.CATALOGManager
FileWriter f = new FileWriter(new File("C:\\Tomcat 5.5\\webapps\\ROOT\
MLEdit\\CATALOG1.xml"));
^
CATALOGMANAGER.java:83: cannot find symbol
symbol : class File
location: class XMLEdit.CATALOGManager
FileWriter f = new FileWriter(new File("C:\\Tomcat 5.5\\webapps\\ROOT\
MLEdit\\CATALOG1.xml"));
^
CATALOGMANAGER.java:84: cannot find symbol
symbol : variable docs
location: class XMLEdit.CATALOGManager
outputter.output(docs, f);
^
CATALOGMANAGER.java:84: cannot find symbol
symbol : variable outputter
location: class XMLEdit.CATALOGManager
outputter.output(docs, f);
^
CATALOGMANAGER.java:106: cannot find symbol
symbol : method seti(int)
location: class XMLEdit.CATALOGManager
d.seti(i);
^
CATALOGMANAGER.java:107: cannot find symbol
symbol : method getname()
location: class XMLEdit.CATALOGManager
System.out.println(d.getname() + "/" + d.getprice());
^
CATALOGMANAGER.java:107: cannot find symbol
symbol : method getprice()
location: class XMLEdit.CATALOGManager
System.out.println(d.getname() + "/" + d.getprice());
^
CATALOGMANAGER.java:115: cannot find symbol
symbol : variable docs
location: class XMLEdit.CATALOGManager
outputter.output(docs, System.out);
^
20 errors
The java code file is as follows from an example I am trying to follow:
package XMLEdit;
import org.jdom.*;
import org.jdom.output.XMLOutputter;
import java.io.IOException;
import org.jdom.input.*;
import org.jdom.output.*;
import java.util.*;
public class CATALOGManager {
Document doc;
List products;
int i = -1;
public void buildDocument(String filename) {
try {
SAXBuilder builder = new SAXBuilder();
doc = builder.build(filename);
products = doc.getRootElement().getChildren();
} catch (JDOMException e) {
e.printStackTrace();
}
}
public void setIndex(int i) {
index = i;
}
public int getNumberofProducts(){
return products.size();
}
public String getId(){
Element product = (Element)products.get(index);
return product.getAttributeValue("id");
}
public String getName(){
Element product = (Element)products.get(i);
return product.getChildText("name");
}
public String getPrice(){
Element product = (Element)products.get(i);
return product.getChildText("price");
}
public void updateCATALOGITEM(String id, String name, String price) {
Element product = (Element)products.get(index);
product.getAttribute("id").setValue(id);
product.getChild("name").setValue(name);
product.getChild("price").setValue(price);
}
public void deleteCATALOGITEM(String id, String name, String price) {
products.remove(index);
}
public void createCATALOG(String id, String name, String price) {
Element product = new Element("product");
product.setAttribute(new Attribute("id", id));
product.addContent(new Element("name").setText(name));
product.addContent(new Element("price").setText(price));
product.add(product);
}
public void sort() {
catalog.sort(products, new Sortname());
}
public void save(String filename) {
XMLOutputter.output(" ",true);
try {
outputter.setTextNormalize(true);
FileWriter f = new FileWriter(new File("C:\\Tomcat 5.5\\webapps\\ROOT\\XMLEdit\\CATALOG1.xml"));
outputter.output(docs, f);
f.close();
} catch (IOException e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
CATALOGManager d = new CATALOGManager();
d.buildDocument(args[0]);
//d.updateCATALOGManager("New NAME", "123");
//d.createCATALOGManager("New NAME2", "1234");
//d.deleteCATALOGManager(0);
//d.deleteCATALOGManager(0);
//d.deleteCATALOGManager(0);
//d.createCATALOGManager("New NAME", "123");
//d.updateCATALOGManager(0, "Next NAME", "7913");
//d.deleteCATALOGManager(0);
//d.outList();
for (int i = 0; i < d.products.size(); i++) {
d.seti(i);
System.out.println(d.getname() + "/" + d.getprice());
}
}
private void outList() {
XMLOutputter outputter = new XMLOutputter();
try {
outputter.output(docs, System.out);
} catch (IOException e) {
e.printStackTrace();
}
}
}
Similar Threads
-
By mdengler in forum ASP.NET
Replies: 0
Last Post: 11-26-2002, 02:32 PM
-
By YC Choo in forum Database
Replies: 5
Last Post: 09-03-2001, 01:42 PM
-
Replies: 4
Last Post: 04-13-2001, 03:31 AM
-
Replies: 1
Last Post: 12-23-2000, 08:42 AM
-
By Ed Pinto in forum VB Classic
Replies: 5
Last Post: 03-22-2000, 12:52 PM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks