-ABerkeley DB: Configuring and Building the Java API
;

Berkeley DB: Configuring and Building the Java API

3Java Compatibility
1Java Installation
)Building Java
JBuilding a shared library version of Berkeley DB
1Building libdb_java
2General Usage Notes



Java Compatibility

GJava DB has been tested with the SunHMicrosystems JDK 1.1 on Windows/NT and SunOS 5.5, and it should workEwith any JDK 1.1 compatible environment. The most important thing toHunderstand is whether the target Java environment supports the JNI (JavaFNative Interface) which we use, rather than some other way for DLLs toDinterface to java. The JNI is new to JDK 1.1, but more likely to be$implementable across many platforms.


Java Installation

JWe expect that you've already installed the Java JDK or equivalent on yourHsystem. Since you are reading this, you also already have a copy of theHBerkeley DB package. For the sake of discussion, we'll assume it's in aKdirectory called db-VERSION, e.g., you extracted Berkeley DB version 2.3.12Jand you did not change the top-level directory name. The files related toJJava are in two subdirectories of db-VERSION: java, the java source files,Fand libdb_java, the C++ files that provide the "glue" between java and1Berkeley DB. The directory tree looks like this:



"                        db-VERSION#                       /          \*                    java        libdb_java%                     |              |&                    src            ...                     |                    com                     |                 sleepycat                /         \                db       examples               |           |              ...         ...


GThis naming conforms to the emerging standard for naming java packages.LWhen the java code is built, it is placed into a classes subdirectory0that is parallel to the src subdirectory.




Building Java

>Both db-VERSION/java and db-VERSION/libdb_java have Makefiles: 

?The java directory can be built using your make command and theDappropriate Makefile. If you've never built java code before, thereCare two things you will need to do before issuing the make command.

JFirst, make sure the java compiler (usually javac) is in your path.LIf you installed the sun JDK distribution in /usr/java , then the java tools#are in the directory /usr/java/bin.

IMake sure your classpath is set correctly. Set your environment variableDCLASSPATH to contain at least the standard class library (perhaps inF/usr/java/lib/classes.zip) and add the Berkeley DB classes in as well."Using the UNIX csh, this might be:



COn Windows/95, your autoexec.bat would need to have something like:



FNote the use of semicolons on Windows. On Windows/NT, you'll set thisvariable in the control panel.

7Now you can run make to build the java directory, e.g.:


=

Building a shared library version of Berkeley DB



See JBuilding a Shared Library Version of Berkeley DB for more information.

HYou MUST build Berkeley DB as a shared library before you proceed beyond this step.




Building libdb_java

GBefore building libdb_java, make sure you have a shared library versionof Berkeley DB (see above).

On UNIX:

GNB: The libdb_java/Makefile.unix Makefile is written to expect that theGsystem compiler is named "gcc" and is the GNU C compiler. In addition,Dit uses compiler-specific options when building. If you are using aHdifferent compiler than gcc, you'll need to modify Makefile.unix to workwith it.

BFirst, edit the line at the beginning of libdb_java/Makefile.unix:



FChange JAVAINSDIR to be the top level directory of your java JDK tree.FThis is the level above the bin and include directories. Then issue a)make command in the libdb_java directory:



On Win/:

4Issue the nmake command in the libdb_java directory:




General Usage Notes

HFor your application to use Db successfully, you must set your CLASSPATHFenvironment variable to include db-VERSION/java/classes as well as theFclasses in your java distribution. See the section above on "BUILDINGJAVA" for further information.

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



9On UNIX, you will want to set LD_LIBRARY_PATH to include:



@These are the locations of your shared libraries. If you get a:

Cexception when you run, chances are you do not have the PATH set up correctly.

BOr, of course, you may copy the built dynamic libraries (libdb and-java_db) to a directory already in your path.

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



D(which should have been built in the "BUILDING JAVA" section above):



DThis example program will prompt for text input lines which are thenFstored with their reversed text in a simple Btree named "db.access" in@your current directly. Try giving it two lines of text and thenHend-of-file. Before it exits, you should see the reversed text. If youErun it again, lines will be there from your previous run. This is anFexcellent check to make sure the fundamental things are working right.

HNOTE: when you run some of the other examples on Solaris, you may get anH"rmutex" libc error message. This is a known bug in Solaris 2.5, and itHis fixed by Sun patch 103187-25. See the Sleepycat Software Release FAQEweb page (www.sleepycat.com) for further information on this problem.ÿÿ