3.3.82, May 07, 2009
These installation notes describe:
JE requires J2SE JDK version 1.5.0_10 or later. You can download the latest J2SE from:
http://java.sun.com/javase/downloads/index.jsp
To install JE, use unzip or tar to unpack the JE distribution. If you are using unzip, be sure to use the -U option to preserve case in file names. For example:
unzip -U je-M.N.P.zip
or
gunzip je-M.N.P.tar.gz
tar xvf je-M.N.P.tar
Unpacking the distribution creates a je-M.N.P directory on disk, where M.N.P is the release's version number. This directory contains the following contents:
bin/
docs/
examples/
lib/
src/
test/
The remainder of this document refers to the je-M.N.P/
directory created in this step as JE_HOME.
To compile and run a program using JE, you only need the je-M.N.P.jar
file in your class path. This file can be
found at:
JE_HOME/lib/je-M.N.P.jar
When using JE within a web container, note that it is important that the JE jar file and your application jar files -- in particular the classes that are being serialized by SerialBinding -- are loaded under the same class loader. For running in a servlet, this typically means that you would place the JE jar file and your application jars in the same directory.
Additionally, it is important to not place the JE jar file in the extensions directory for your JVM. Instead place the JE jar file in the same location as your application jars. The extensions directory is reserved for privileged library code.
For using JE with Android, see the Android HOWTO.
To uninstall, just remove the directory that you unzipped into.
The JE distribution comes with examples that illustrate:
The complete list of examples follows.
Example | Location | API | Description |
---|---|---|---|
Getting Started Guide | examples/persist/ gettingStarted | DPL | scenarios using the Direct Persistence Layer from the Getting Started Guide |
Writing Transactional Applications | examples/persist/txn | DPL | scenarios using the Direct Persistence Layer from Writing Transactional Applications |
Writing Transactional Applications | examples/je/txn | Base | scenarios using the Base API from Writing Transactional Applications |
Translating SQL Queries | examples/persist/sqlApp | DPL | shows how some common SQL queries can be implemented using the Direct Persistence Layer |
PersonExample | examples/persist | DPL | demonstrates basic use of the Direct Persistence Layer |
ScalaPersonExample | examples/persist | DPL | demonstrates using JE with the Scala programming language |
EventExample EventExampleDPL | examples/persist | DPL | contrasts the Base API and the Direct Persistence Layer with an example of storing event objects |
CustomKeyOrderExample | examples/persist | DPL | shows how to use a Comparable to specify key order |
DplDump | examples/persist | DPL | dumps objects stored using the Direct Persistence Layer in XML format |
HelloDatabaseWorld | examples/collections/hello | Collections | trivial example using the Collections API |
AccessExample | examples/collections/access | Collections | reimplementation of the Base API AccessExample using the Collections API |
Shipments | examples/collections/ship | Collections | series of examples based on a shipment database |
SimpleExample | examples/je | Base | does basic data insertion and retrieval |
BindingExample | examples/je | Base | shows how to use com.sleepycat.bind to convert between Java objects and JE data records |
SecondaryExample | examples/je | Base | illustrates the use of secondary indices |
SequenceExample | examples/je | Base | demonstrates the use of Sequence objects |
ToManyExample | examples/je | Base | shows how to use multi-key secondary indices to support many-many and one-many primary/secondary key relationships |
MeasureInsertSize | examples/je | Base | inserts a given set of key/value pairs in order to measure the disk space consumed by a given data set |
JCA | examples/jca | Base | shows how to use the J2EE Connector Architecture with JE |
JMX | examples/jmx | Base | shows how to use the Java Management Extensions with JE |
Compiling and running a simple example can serve as a sanity check of the installation. Follow the instructions below to compile and run the PersonExample.
You can find the source for this example at:
JE_HOME/examples/persist/PersonExample.java
Assuming you have installed the J2SE JDK and have verified that you
have a working Java compiler, you can build PersonExample
as follows.
JE_HOME/examplesdirectory.
JE_HOME/lib/je-M.N.P.jarand the
JE_HOME/examplesdirectory.
PersonExample.java
with the following command:
javac persist/PersonExample.javaor on Windows:
javac persist\PersonExample.java
To run PersonExample
, use the following command, specifying an
environment directory for the data generated by the example:
java persist.PersonExample -h <environment directory>
For example, using "."
for the second parameter will write
the database files into the current directory. You'll notice that a
00000000.jdb
file and and je.lck
file are
created. This is the first log file in the environment and a lock
file. If you need to delete the environment for running a different
example, simply delete these two files.
When you run the program you'll see the following output. While this is not a very entertaining program, it is enough to test that you have installed JE correctly.
222-22-2222 Jack Smith 333-33-3333 Mary Smith
The other JE examples are compiled and run similarly. How to the run examples from the Getting Started Guide and Writing Transactional Applications is described in the sections below, as well as how to run the Translating SQL Queries examples. Instructions for running other examples are contained in the example's source file.
As described in the Berkeley DB Java Edition Getting Started Guide, the final examples in every chapter exist in the JE package. You can build and run these examples as follows:
JE_HOME/examplesdirectory.
JE_HOME/lib/je-M.N.P.jarand the
JE_HOME/examplesdirectories.
javac je/gettingStarted/*.javaor on Windows:
javac je\gettingStarted\*.java
mkdir gsgEnv
java je.gettingStarted.ExampleDatabasePut -h gsgEnv -i je/gettingStarted/inventory.txt -v je/gettingStarted/vendors.txt
java je.gettingStarted.ExampleInventoryRead -h gsgEnvTo perform a query based on an inventory item's name, use:
java je.gettingStarted.ExampleInventoryRead -h gsgEnv -s Upo
The examples in Writing Transactional Applications with Berkeley DB, Java Edition guide exist in the JE package. You can build and run these examples as follows:
JE_HOME/examplesdirectory.
JE_HOME/lib/je-M.N.P.jarand the
JE_HOME/examplesdirectories.
javac je/txn/*.javaor on Windows:
javac je\txn\*.java
mkdir txnEx
java je.txn.TxnGuide -h txnEx
This example shows how some common SQL queries can be implemented using the Direct Persistence Layer. It's meant to help users who are more familiar with SQL translate those approaches to the DPL. These queries include:
SELECT * FROM tab ORDER BY col ASC;
SELECT * FROM tab WHERE col LIKE 'prefix%';
SELECT * FROM tab WHERE col gt;= A AND col <= B;
SELECT * FROM tab WHERE col1 = A AND col2 =B;
SELECT t1.* FROM table1 t1, table2 t2 WHERE t1.col1 = t2.col1
AND t2.col2 = A;
You can build and run these examples as follows:
JE_HOME/examplesdirectory.
JE_HOME/lib/je-M.N.P.jarand the
JE_HOME/examplesdirectories.
javac persist/sqlapp/*.javaor on Windows:
javac persist\sqlapp\*.java
mkdir sqlEnv
java persist.sqlapp.SQLApp -h sqlEnvTo delete database files after the example exits, do:
java persist.sqlapp.SQLApp -h sqlEnv -d
JE must be built with Java 1.5.0_10 or later. To build JE from the provided source, you need to download and install Ant 1.7.0 or later and JUnit:
Apache Ant
See the next section for downloading JUnit. Once ant and JUnit are installed, you can build JE using the following command:
cd JE_HOMEant clean jar
The JE jar file will appear in JE_HOME/build/lib/je-M.N.P.jar.
By default, JE is compiled with both -O for optimization and -g for debug symbols. Compiling without the -g will give you the smallest possible JE jar file. To do so, edit the JE_HOME/ant/compile.xml file and change the build.debug property from "on" to "off".
If you want to build and run the included unit tests, you must download JUnit:
JUnit/SourceForge
Once JUnit is installed on your system, you must make sure that ant knows about it. The simplest way to do this is to copy the junit.jar file into your ant's lib dir. You then must build JE as follows:
cd JE_HOMEant clean compile
Once it is compiled, you can run the unit tests using the command:
"ant test"
. The unit tests usually take between 20 to 50
minutes to run, depending on platform. On some platforms, notably
Windows, you may see OutOfMemoryErrors while running the unit
tests. To avoid this, increase the JVM maximum memory size by setting
the ANT_OPTS environment variable so that it includes
-Xmx256M.
You can use the following build options when building JE:
Option | Description |
---|---|
clean | Removes any previously built classes and jar files. |
compile | Compiles JE and the included unit tests. This requires JUnit be downloaded and installed on your system. See Building and Running the Unit Tests for more information. |
compile-src | Compiles JE. The unit tests are not compiled. |
jar |
Creates the JE jar file in build/lib/je-M.N.P.jar. |
test | Runs unit tests. |
install | Unix systems only. Causes the JE bin, lib,
and docs directories to be installed to:/usr/lib/JE.<major>.<minor>where <major> is the JE major release number, and <minor> is the JE minor release number. If you do not want JE installed into /usr/lib, then you can change the base installation directory using -Dinstalldir. For example: ant install -Dinstalldir=/usr/local |
JE can be used as a J2EE/JCA Resource Adapter. It has been tested with Oracle Application Server (OC4J) 10.1.3.2.0, JBoss 3.2.6 and Sun Java System Application Server 8.1. For cookbook style "HOWTO's" using the JE J2EE/JCA Resource Adapter see JE_HOME/examples/jca/HOWTO-oc4j.txt, JE_HOME/examples/jca/HOWTO-jboss.txt and JE_HOME/examples/jca/HOWTO-sjsas.txt.
JE supplies a ready to install JMX (Java Management Extensions) MBean as well as support for adding JE monitoring to an application's custom MBean. See JE_HOME/examples/jmx/README.txt.
Copyright (c) 2002,2009 Oracle. All rights reserved.