Debian Codegraph @

docs/programmer_reference/java.html

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