Running the Sample Programs

To run a sample you must change to the sample directory containing the source files and your classpath must include the current directory (.), and db.jar. See the top-level reference guide for installation instructions.

For example:

$ cd samples/db/helloworld
$ javac -g *.java
$ mkdir tmp
$ java HelloDatabaseWorld

If a compilation error or exception occurs, check your installation.

The 'tmp' subdirectory is used to store the Berkeley DB environment and database files. If the database files are missing or empty then the sample program will write the sample data; otherwise, it will only read and print the existing data. To force the sample to write the data, delete the 'tmp' subdirectory before running the sample.

If you are interested on examining the database files you can use the supplied standard db_* DB command line utility programs with the database files in the 'tmp' subdirectory.

$ cd samples/db/helloworld
$ db_dump -h tmp data.db

Will dump the binary contents of the helloworld data store.

For more information on each sample see the README.txt file in the sample directory and the sample source code.