Building the Java API
Prev | Chapter 28. Building Berkeley DB for Windows | Next

## Building the Java API

Java support is not built automatically. The following instructions assume that you have installed the Sun Java Development Kit in `d:\java`. Of course, if you installed elsewhere or have different Java software, you will need to adjust the pathnames accordingly.

### Building Java with Visual C++ .NET or above

1. Set your include directories. Choose Tools -> Options -> Projects -> VC++ Directories. Under the "Show directories for" pull-down, select "Include files". Add the full pathnames for the `d:\java\include` and `d:\java\include\win32` directories. Then click OK. These are the directories needed when including jni.h.
2. Set the executable files directories. Choose Tools -> Options -> Projects -> VC++ Directories. Under the "Show directories for" pull-down, select "Executable files". Add the full pathname for the `d:\java\bin` directory, then click OK. This is the directory needed to find javac.
3. Set the build type to Release or Debug in the drop-down on the tool bar.

4. To build, right-click on db_java and select Build. This builds the Java support library for Berkeley DB and compiles all the java files, placing the resulting `db.jar` and `dbexamples.jar` files in one of the following Berkeley DB subdirectories, depending on the configuration that you chose:

   `build_windows\Win32\Debug`
   `build_windows\Win32\Release`

### Building Java with Visual C++ 6.0

1. Set the include directories. Choose Tools -> Options -> Directories. Under the "Show directories for" pull-down, select "Include files". Add the full pathnames for the `d:\java\include` and `d:\java\include\win32` directories. These are the directories needed when including `jni.h`.
2. Set the executable files directories. Choose Tools -> Options -> Directories. Under the "Show directories for" pull-down, select "Executable files". Add the full pathname for the `d:\java\bin` directory. This is the directory needed to find javac.
3. Go to Build -> Set Active Configuration and select either the Debug or Release version of the db_java project. Then press OK.

4. To build, select Build -> Build libdb_java48.dll. This builds the Java support library for Berkeley DB and compiles all the java files, placing the resulting `db.jar` and `dbexamples.jar` files in one of the following Berkeley DB subdirectories, depending on the configuration that you chose:

   `build_windows\Win32\Debug`
   `build_windows\Win32\Release`

To run Java code, set your environment variable `CLASSPATH` to include the full pathname of these jar files, and your environment variable `PATH` to include the `build_windows\Win32\Release` subdirectory. On Windows, remember that files or directories in the `CLASSPATH` and `PATH` variables must be separated by semicolons (unlike UNIX). Then, try running the following command as a test:

    java db.AccessExample

If you want to run Java code using a Debug build, substitute 'Debug' for 'Release' in the instructions above. Make sure you use the Debug JAR file with the Debug DLL and the Release JAR with the Release DLL.

Prev | Up | Next
Building the C++ STL API | Home | Building the C# API