summaryrefslogtreecommitdiff
path: root/db/docs/ref/java/conf.html
blob: b3ffb485a074b64d5f381bb50980eb81aafee42b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<!--$Id: conf.so,v 10.30 2005/12/01 03:18:51 bostic Exp $-->
<!--Copyright 1997-2006 by Oracle Corporation-->
<!--All rights reserved.-->
<!--See the file LICENSE for redistribution information.-->
<html>
<head>
<title>Berkeley DB Reference Guide: Java configuration</title>
<meta name="description" content="Berkeley DB: An embedded database programmatic toolkit.">
<meta name="keywords" content="embedded,database,programmatic,toolkit,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,Java,C,C++">
</head>
<body bgcolor=white>
<a name="2"><!--meow--></a>
<table width="100%"><tr valign=top>
<td><h3><dl><dt>Berkeley DB Reference Guide:<dd>Java API</dl></h3></td>
<td align=right><a href="../am_misc/faq.html"><img src="../../images/prev.gif" alt="Prev"></a><a href="../toc.html"><img src="../../images/ref.gif" alt="Ref"></a><a href="../java/compat.html"><img src="../../images/next.gif" alt="Next"></a>
</td></tr></table>
<p>
<h3 align=center>Java configuration</h3>
<p>Building the Berkeley DB java classes, the examples and the native support
library is integrated into the normal build process.  See
<a href="../../ref/build_unix/conf.html#--enable-java">Configuring
Berkeley DB</a> and <a href="../../ref/build_win/intro.html">Building for Windows</a>
for more information.</p>
<p>We expect that you already installed the Java JDK or equivalent on your
system.  For the sake of discussion, we assume that it is in a directory
called db-VERSION; for example, you downloaded a Berkeley DB archive, and you
did not change the top-level directory name.  The files related to Java
are in three subdirectories of db-VERSION: java (the java source files),
libdb_java (the C++ files that provide the "glue" between java and
Berkeley DB) and examples_java (containing all examples code).  The directory
tree looks like this:</p>
<blockquote><pre>db-VERSION
|-- java
|   `-- src
|       `-- com
|           `-- sleepycat
|               |-- bdb
|               |   |-- ...
|               |   |-- bind
|               |   |   `-- ...
|               |   `-- util
|               |       `-- ...
|               `-- db
|-- examples_java
|   `-- src
|       `-- com
|           `-- sleepycat
|               `-- examples
|                   |-- bdb
|                   |   `-- ...
|                   `-- db
|                       `-- ...
`-- libdb_java
    `-- ...
</pre></blockquote>
<p>This naming conforms to the de facto standard for naming java packages.
When the java code is built, it is placed into two jar files:
<b>db.jar</b>, containing the db package,
and <b>dbexamples.jar</b>, containing the examples.</p>
<p>For your application to use Berkeley DB successfully, you must set your
<b>CLASSPATH</b> environment variable to include the full pathname of
the db jar files as well as the classes in your java distribution.
On UNIX, <b>CLASSPATH</b> is a colon-separated
list of directories and jar files;
on Windows, it is separated by semicolons.
On UNIX, the jar files are put in your build directory, and when
you do the make install step, they are copied to the lib directory
of your installation tree.  On Windows, the jar files are placed
in the Release or Debug subdirectory with your other objects.</p>
<p>The Berkeley DB Java classes are mostly implemented in native
methods. Before you can use them, you need to make sure that the
DLL or shared library containing the native methods can be found
by your Java runtime.  On Windows, you should set your PATH variable
to include:</p>
<blockquote><pre><b>db-VERSION\build_windows\Release</b></pre></blockquote>
<p>On UNIX, you should set the
<b>LD_LIBRARY_PATH</b> environment variable or local equivalent
to include the Berkeley DB library installation directory. Of course, the
standard install directory may have been changed for your site; see your
system administrator for details.</p>
<p>On other platforms, the path can be set on the command line as follows
(assuming the shared library is in <b>/usr/local/BerkeleyDB/lib</b>:)</p>
<blockquote><pre>% java -Djava.library.path=/usr/local/BerkeleyDB/lib ...</pre></blockquote>
<p>Regardless, if you get the following exception when you run, you
probably do not have the library search path configured correctly:</p>
<blockquote><pre>java.lang.UnsatisfiedLinkError</pre></blockquote>
<p>Different Java interpreters provide different error messages if the
<b>CLASSPATH</b> value is incorrect, a typical error is the following:</p>
<blockquote><pre>java.lang.NoClassDefFoundError</pre></blockquote>
<p>To ensure that everything is running correctly, you may want to try a
simple test from the example programs in</p>
<blockquote><pre><b>db-VERSION/examples_java/src/db</b></pre></blockquote>
<p>For example, the following sample program will prompt for text input
lines, which are then stored in a Btree database named <b>access.db</b> in
your current directory:</p>
<blockquote><pre>% java db.AccessExample</pre></blockquote>
<p>Try giving it a few lines of input text and then end-of-file.  Before
it exits, you should see a list of the lines you entered display with
data items.  This is a simple check to make sure the fundamental
configuration is working correctly.</p>
<table width="100%"><tr><td><br></td><td align=right><a href="../am_misc/faq.html"><img src="../../images/prev.gif" alt="Prev"></a><a href="../toc.html"><img src="../../images/ref.gif" alt="Ref"></a><a href="../java/compat.html"><img src="../../images/next.gif" alt="Next"></a>
</td></tr></table>
<p><font size=1>Copyright (c) 1996-2006 Oracle Corporation - All rights reserved.</font>
</body>
</html>