Eric -

Sounds like you might need to set the CLASSPATH environment variable to include the com.sleepycat.dbxml.* libraries.  That would be either a directory of class files or a .jar file.  Make sure that the sleepycat stuff is in your classpath then try compiling it again with:



-----Original Message-----
From: Eric Lease Morgan <[log in to unmask]>
Sent: Jul 5, 2004 12:16 PM
To: [log in to unmask]
Subject: [CODE4LIB] compiling a BerkeleyDBXML  Java program

Can y'all help me compile a BerkeleyDBXML Java program?

I have compiled and installed BerkeleyDB (version 4.2) and
BerkeleyDBXML (version 1.2) on my Linux host with the Java (version
1.4.2-rc1), I think. I know nothing about Java. I found a simple Java
program that should allow me to to add, update, delete, get, and query
XML files using the BerkeleyDBXML libraries (see, below:

   import com.sleepycat.dbxml.*;

   public class Tool {
        XmlContainer db = null;
        public static void main(String[] args) throws
          Exception {
          String database = args[0];
          String action = args[1];
          String param = args[2];
          Database db = new Database(database);
          if (action.equalsIgnoreCase("add")) {
                int id = db.insertDocument(readFile(param));
                System.out.println("Inserted document " +
                  param +
                  " as id: " + id);
          else if (action.equalsIgnoreCase("delete")) {
                int key = Integer.parseInt(param);
                System.out.println("Document id " + key +
                  " deleted.");
          else if (action.equalsIgnoreCase("get")) {
                int key = Integer.parseInt(param);
                XmlDocument document = db.getDocument(key);
          else if (action.equalsIgnoreCase("update")) {
                int key = Integer.parseInt(param);
                String newContent = readFile(args[3]);
                db.updateDocument(key, newContent);
                System.out.println("Document id " + key +
                  " updated.");
          else if (action.equalsIgnoreCase("query")) {
                String result = db.xpathQueryAsString(param);
        public static String readFile(String param)
          throws Exception {
          BufferedReader in = new BufferedReader(new
          StringBuffer buffer = new StringBuffer();
          String line;
          while ((line = in.readLine()) != null) {
          return buffer.toString();

I try to compile this code with the following command:


But it returns the following error: cannot resolve symbol
   symbol  : class Database
   location: class Tool
          Database db = new Database(database);
          ^ cannot resolve symbol
   symbol  : class Database
   location: class Tool
          Database db = new Database(database);

What do I need to do (with line #11) in order to make a Tool.jar file?
Does the error mean that "Database" is not a valid function call in the
BerkeleyDBXML libraries?

Eric "Clueless" Morgan