|
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 Windows for more information.
We expect that you've already installed the Java JDK or equivalent on your system. Since you are reading this, you also already have a copy of the Berkeley DB package. For the sake of discussion, we'll assume it is in a directory called db-VERSION, e.g., you extracted Berkeley DB version 2.3.12 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.
On Windows, you will want to set your PATH variable to include:
db-VERSION/build_win32/Debug
On UNIX, you will want to set LD_LIBRARY_PATH to include:
db-VERSION/build_unix/.libs
These is where libraries are found after Berkeley DB has been built, but before the install step. If you are using Berkeley DB on UNIX, and Berkeley DB has already been installed, your shared libraries will be installed into a "libs" subdirectory under the top-level installation directory. However, the standard install directory may have been changed for your site, see your system administrator for details. Regardless, if you get a:
java.lang.UnsatisfiedLinkError
exception when you run, chances are you do not have the search path configured correctly.
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 sample program:
% java com.sleepycat.examples.AccessExample
will prompt for text input lines which are then stored with their reversed text in a Btree database named "access.db" in your current directory. Try giving it a few lines of input text and then end-of-file. Before it exits, you should see the reversed text. This is a simple check to make sure the fundamental configuration is working correctly.