Berkeley DB Reference Guide: Configuration
Description: Berkeley DB: An embedded database programmatic toolkit.
Keywords: embedded,database,programmatic,toolkit,b+tree,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,java,C,C++

### Berkeley DB Reference Guide: Java API |

# Configuration

Building the Berkeley DB java classes, the examples and the native support library is integrated into the normal build process. See Configuring Berkeley DB and Building for Win32 for more information.

We expect that you already installed the Java JDK or equivalent on your system. For the sake of discussion, we assume that it is in a directory called db-VERSION; for example, you downloaded a Berkeley DB archive, and you did not change the top-level directory name. The files related to Java are in two subdirectories of db-VERSION: java (the java source files) and libdb_java (the C++ files that provide the "glue" between java and Berkeley DB). The directory tree looks like this:

>     		db-VERSION
>     	       /          \
>     	    java        libdb_java
>     	     |              |
>     	    src            ...
>     	     |
>     	    com
>     	     |
>     	 sleepycat
>     	/         \
>            db       examples
>            |           |
>           ...         ...

This naming conforms to the emerging standard for naming java packages. When the java code is built, it is placed into a classes subdirectory that is parallel to the src subdirectory.

For your application to use Berkeley DB successfully, you must set your CLASSPATH environment variable to include db-VERSION/java/classes as well as the classes in your java distribution. On UNIX, CLASSPATH is a colon-separated list of directories; on Windows, it is separated by semicolons. Alternatively, you can set your CLASSPATH to include db-VERSION/java/classes/db.jar, which is created as a result of the build. The db.jar file contains the classes in com.sleepycat.db; it does not contain any classes in com.sleepycat.examples.

On Windows, you will want to set your PATH variable to include

>     db-VERSION\build_win32\Release

On UNIX, you will want to set the LD_LIBRARY_PATH environment variable to include the Berkeley DB library installation directory. Of course, the standard install directory may have been changed for your site; see your system administrator for details. Regardless, if you get the following exception when you run, you probably do not have the library search path configured correctly:

>     java.lang.UnsatisfiedLinkError

Different Java interpreters provide different error messages if the CLASSPATH value is incorrect, a typical error is the following:

>     java.lang.NoClassDefFoundError

To ensure that everything is running correctly, you may want to try a simple test from the example programs in

>     db-VERSION/java/src/com/sleepycat/examples

For example, the following sample program will prompt for text input lines, which are then stored in a Btree database named "access.db" in your current directory:

>     % java com.sleepycat.examples.AccessExample

Try giving it a few lines of input text and then end-of-file. Before it exits, you should see a list of the lines you entered display with data items. This is a simple check to make sure the fundamental configuration is working correctly.

Copyright Sleepycat Software