• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt-6.x.4708/router/db-4.8.30/docs/programmer_reference/
1<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3<html xmlns="http://www.w3.org/1999/xhtml">
4  <head>
5    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
6    <title>Chapter��5.�� Java API</title>
7    <link rel="stylesheet" href="gettingStarted.css" type="text/css" />
8    <meta name="generator" content="DocBook XSL Stylesheets V1.73.2" />
9    <link rel="start" href="index.html" title="Berkeley DB Programmer's Reference Guide" />
10    <link rel="up" href="index.html" title="Berkeley DB Programmer's Reference Guide" />
11    <link rel="prev" href="am_misc_faq.html" title="Access method FAQ" />
12    <link rel="next" href="java_compat.html" title="Compatibility" />
13  </head>
14  <body>
15    <div class="navheader">
16      <table width="100%" summary="Navigation header">
17        <tr>
18          <th colspan="3" align="center">Chapter��5.��
19		Java API
20        </th>
21        </tr>
22        <tr>
23          <td width="20%" align="left"><a accesskey="p" href="am_misc_faq.html">Prev</a>��</td>
24          <th width="60%" align="center">��</th>
25          <td width="20%" align="right">��<a accesskey="n" href="java_compat.html">Next</a></td>
26        </tr>
27      </table>
28      <hr />
29    </div>
30    <div class="chapter" lang="en" xml:lang="en">
31      <div class="titlepage">
32        <div>
33          <div>
34            <h2 class="title"><a id="java"></a>Chapter��5.��
35		Java API
36        </h2>
37          </div>
38        </div>
39      </div>
40      <div class="toc">
41        <p>
42          <b>Table of Contents</b>
43        </p>
44        <dl>
45          <dt>
46            <span class="sect1">
47              <a href="java.html#java_conf">Java configuration</a>
48            </span>
49          </dt>
50          <dt>
51            <span class="sect1">
52              <a href="java_compat.html">Compatibility</a>
53            </span>
54          </dt>
55          <dt>
56            <span class="sect1">
57              <a href="java_program.html">Java programming notes</a>
58            </span>
59          </dt>
60          <dt>
61            <span class="sect1">
62              <a href="java_faq.html">Java FAQ</a>
63            </span>
64          </dt>
65        </dl>
66      </div>
67      <div class="sect1" lang="en" xml:lang="en">
68        <div class="titlepage">
69          <div>
70            <div>
71              <h2 class="title" style="clear: both"><a id="java_conf"></a>Java configuration</h2>
72            </div>
73          </div>
74        </div>
75        <p>Building the Berkeley DB java classes, the examples and the native support
76library is integrated into the normal build process.  See
77<a class="xref" href="build_unix_conf.html" title="Configuring Berkeley DB">Configuring Berkeley DB</a> and 
78<a class="xref" href="build_win_java.html" title="Building the Java API">Building the Java API</a>
79for more information.</p>
80        <p>We expect that you already installed the Java JDK or equivalent on your
81system.  For the sake of discussion, we assume that it is in a directory
82called db-VERSION; for example, you downloaded a Berkeley DB archive, and you
83did not change the top-level directory name.  The files related to Java
84are in three subdirectories of db-VERSION: java (the java source files),
85libdb_java (the C++ files that provide the "glue" between java and
86Berkeley DB) and examples_java (containing all examples code).  The directory
87tree looks like this:</p>
88        <pre class="programlisting">db-VERSION
89|-- java
90|   `-- src
91|       `-- com
92|           `-- sleepycat
93|               |-- bind
94|               |-- db
95|               |   `-- ...
96|               `-- util
97|-- examples_java
98|   `-- src
99|       `-- db
100|           `-- ...
101`-- libdb_java
102    `-- ...
103</pre>
104        <p>This naming conforms to the de facto standard for naming java packages.
105When the java code is built, it is placed into two jar files:
106<code class="filename">db.jar</code>, containing the db package,
107and <code class="filename">dbexamples.jar</code>, containing the examples.</p>
108        <p>For your application to use Berkeley DB successfully, you must set your
109<code class="literal">CLASSPATH</code> environment variable to include the full pathname of
110the db jar files as well as the classes in your java distribution.
111On UNIX, <code class="literal">CLASSPATH</code> is a colon-separated
112list of directories and jar files;
113on Windows, it is separated by semicolons.
114On UNIX, the jar files are put in your build directory, and when
115you do the make install step, they are copied to the lib directory
116of your installation tree.  On Windows, the jar files are placed
117in the Release or Debug subdirectory with your other objects.</p>
118        <p>The Berkeley DB Java classes are mostly implemented in native
119methods. Before you can use them, you need to make sure that the
120DLL or shared library containing the native methods can be found
121by your Java runtime.  On Windows, you should set your PATH variable
122to include:</p>
123        <pre class="programlisting">
124          <code class="filename">db-VERSION\build_windows\Release</code>
125        </pre>
126        <p>On UNIX, you should set the
127<code class="literal">LD_LIBRARY_PATH</code> environment variable or local equivalent
128to include the Berkeley DB library installation directory. Of course, the
129standard install directory may have been changed for your site; see your
130system administrator for details.</p>
131        <p>On other platforms, the path can be set on the command line as follows
132(assuming the shared library is in <code class="filename">/usr/local/BerkeleyDB/lib</code>:)</p>
133        <pre class="programlisting">% java -Djava.library.path=/usr/local/BerkeleyDB/lib ...</pre>
134        <p>Regardless, if you get the following exception when you run, you
135probably do not have the library search path configured correctly:</p>
136        <pre class="programlisting">java.lang.UnsatisfiedLinkError</pre>
137        <p>Different Java interpreters provide different error messages if the
138<code class="literal">CLASSPATH</code> value is incorrect, a typical error is the following:</p>
139        <pre class="programlisting">java.lang.NoClassDefFoundError</pre>
140        <p>To ensure that everything is running correctly, you may want to try a
141simple test from the example programs in</p>
142        <pre class="programlisting">
143          <code class="filename">db-VERSION/examples_java/src/db</code>
144        </pre>
145        <p>For example, the following sample program will prompt for text input
146lines, which are then stored in a Btree database named <code class="filename">access.db</code> in
147your current directory:</p>
148        <pre class="programlisting">% java db.AccessExample</pre>
149        <p>Try giving it a few lines of input text and then end-of-file.  Before
150it exits, you should see a list of the lines you entered display with
151data items.  This is a simple check to make sure the fundamental
152configuration is working correctly.</p>
153      </div>
154    </div>
155    <div class="navfooter">
156      <hr />
157      <table width="100%" summary="Navigation footer">
158        <tr>
159          <td width="40%" align="left"><a accesskey="p" href="am_misc_faq.html">Prev</a>��</td>
160          <td width="20%" align="center">��</td>
161          <td width="40%" align="right">��<a accesskey="n" href="java_compat.html">Next</a></td>
162        </tr>
163        <tr>
164          <td width="40%" align="left" valign="top">Access method FAQ��</td>
165          <td width="20%" align="center">
166            <a accesskey="h" href="index.html">Home</a>
167          </td>
168          <td width="40%" align="right" valign="top">��Compatibility</td>
169        </tr>
170      </table>
171    </div>
172  </body>
173</html>
174