ibm-information-center/dist/eclipse/plugins/i5OS.ic.rzaha_5.4.0.1/rzahapaseexmplslibrary.htm

164 lines
9.7 KiB
HTML

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en-us" xml:lang="en-us">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="security" content="public" />
<meta name="Robots" content="index,follow" />
<meta http-equiv="PICS-Label" content='(PICS-1.1 "http://www.icra.org/ratingsv02.html" l gen true r (cz 1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l gen true r (n 0 s 0 v 0 l 0) "http://www.classify.org/safesurf/" l gen true r (SS~~000 1))' />
<meta name="DC.Type" content="concept" />
<meta name="DC.Title" content="Managing native method libraries" />
<meta name="abstract" content="To use native method libraries, especially when you want to manage multiple versions of a native method library on your iSeries server, you need to understand both the Java library naming conventions and the library search algorithm." />
<meta name="description" content="To use native method libraries, especially when you want to manage multiple versions of a native method library on your iSeries server, you need to understand both the Java library naming conventions and the library search algorithm." />
<meta name="DC.Relation" scheme="URI" content="rzahapaseexmplsmain.htm" />
<meta name="DC.Relation" scheme="URI" content="rzahapasejavaenvvariables.htm" />
<meta name="DC.Relation" scheme="URI" content="rzahapaseerrors.htm" />
<meta name="DC.Relation" scheme="URI" content="rzahapaseexmpls.htm" />
<meta name="copyright" content="(C) Copyright IBM Corporation 2006" />
<meta name="DC.Rights.Owner" content="(C) Copyright IBM Corporation 2006" />
<meta name="DC.Format" content="XHTML" />
<meta name="DC.Identifier" content="rzahapaseexmplslibrary" />
<meta name="DC.Language" content="en-us" />
<!-- All rights reserved. Licensed Materials Property of IBM -->
<!-- US Government Users Restricted Rights -->
<!-- Use, duplication or disclosure restricted by -->
<!-- GSA ADP Schedule Contract with IBM Corp. -->
<link rel="stylesheet" type="text/css" href="./ibmdita.css" />
<link rel="stylesheet" type="text/css" href="./ic.css" />
<title>Managing native method libraries</title>
</head>
<body id="rzahapaseexmplslibrary"><a name="rzahapaseexmplslibrary"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Managing native method libraries</h1>
<div><p>To use native method libraries, especially when you want to manage
multiple versions of a native method library on your iSeries™ server, you need to understand
both the Java™ library naming conventions and the library search
algorithm.</p>
<p><span class="keyword">i5/OS™</span> uses the first
native method library that matches the name of the library that the Java virtual
machine (JVM) loads. In order to ensure that <span class="keyword">i5/OS</span> finds
the correct native methods, you must avoid library name clashes and confusion
about which native method library the JVM uses.</p>
<div class="section"><h4 class="sectiontitle"><span class="keyword">i5/OS</span> PASE
and AIX<sup>®</sup> Java Library
Naming Conventions</h4><p>If the Java code loads a library named Sample,
the corresponding executable file must be named either libSample.a or libSample.so.</p>
</div>
<div class="section"><h4 class="sectiontitle">Java library search order</h4><p>When you enable <span class="keyword">i5/OS</span> PASE native methods for the
JVM, your server uses three different lists (in the following order) to create
a single native method library search path:</p>
<ol><li><span class="keyword">i5/OS</span> library list</li>
<li>LIBPATH environment variable</li>
<li>PASE_LIBPATH environment variable</li>
</ol>
<p>In order to perform the search, <span class="keyword">i5/OS</span> converts
the library list to the integrated file system format. QSYS file system objects
have equivalent names in the integrated file system, but some integrated file
system objects do not have equivalent QSYS file system names. Because the
library loader looks for objects in both the QSYS file system and in the integrated
file system, <span class="keyword">i5/OS</span> uses
the integrated file system format to search for native method libraries.</p>
<p>The
following table shows how <span class="keyword">i5/OS</span> converts
entries in the library list to the integrated file system format:</p>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" width="100%" frame="border" border="1" rules="all"><thead align="left"><tr><th valign="top" id="d0e90">Library list entry</th>
<th valign="top" id="d0e92">Integrated file system format</th>
</tr>
</thead>
<tbody><tr><td valign="top" headers="d0e90 ">QSYS</td>
<td valign="top" headers="d0e92 ">/qsys.lib</td>
</tr>
<tr><td valign="top" headers="d0e90 ">QSYS2</td>
<td valign="top" headers="d0e92 ">/qsys.lib/qsys2.lib</td>
</tr>
<tr><td valign="top" headers="d0e90 ">QGPL</td>
<td valign="top" headers="d0e92 ">/qsys.lib/qgpl.lib</td>
</tr>
<tr><td valign="top" headers="d0e90 ">QTEMP</td>
<td valign="top" headers="d0e92 ">/qsys.lib/qtemp.lib</td>
</tr>
</tbody>
</table>
</div>
<p><strong>Example: Searching for the Sample2 library</strong></p>
<p>In the
following example, LIBPATH is set to /home/user1/lib32:/samples/lib32 and
PASE_LIBPATH is set to /QOpenSys/samples/lib.</p>
<p>The following table, when
read from top to bottom, indicates the full search path:</p>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" width="100%" frame="border" border="1" rules="all"><thead align="left"><tr><th valign="top" id="d0e128">Source</th>
<th valign="top" id="d0e130">Integrated file system directories</th>
</tr>
</thead>
<tbody><tr><td valign="top" headers="d0e128 ">Library list</td>
<td valign="top" headers="d0e130 "><p>/qsys.lib<br />
/qsys.lib/qsys2.lib<br />
/qsys.lib/qgpl.lib<br />
/qsys.lib/qtemp.lib</p>
</td>
</tr>
<tr><td valign="top" headers="d0e128 ">LIBPATH</td>
<td valign="top" headers="d0e130 "><p>/home/user1/lib32<br />
/samples/lib32</p>
</td>
</tr>
<tr><td valign="top" headers="d0e128 ">PASE_LIBPATH</td>
<td valign="top" headers="d0e130 ">/QOpenSys/samples/lib</td>
</tr>
</tbody>
</table>
</div>
<div class="note"><span class="notetitle">Note:</span> Uppercase and lowercase characters are significant only in the
/QOpenSys path.</div>
<p>In order to search for library Sample2, the Java library
loader searches for file candidates in the following order:</p>
<ol><li>/qsys.lib/sample2.srvpgm</li>
<li>/qsys.lib/libSample2.a</li>
<li>/qsys.lib/libSample2.so</li>
<li>/qsys.lib/qsys2.lib/sample2.srvpgm</li>
<li>/qsys.lib/qsys2.lib/libSample2.a</li>
<li>/qsys.lib/qsys2.lib/libSample2.so</li>
<li>/qsys.lib/qgpl.lib/sample2.srvpgm</li>
<li>/qsys.lib/qgpl.lib/libSample2.a</li>
<li>/qsys.lib/qgpl.lib/libSample2.so</li>
<li>/qsys.lib/qtemp.lib/sample2.srvpgm</li>
<li>/qsys.lib/qtemp.lib/libSample2.a</li>
<li>/qsys.lib/qtemp.lib/libSample2.so</li>
<li>/home/user1/lib32/sample2.srvpgm</li>
<li>/home/user1/lib32/libSample2.a</li>
<li>/home/user1/lib32/libSample2.so</li>
<li>/samples/lib32/sample2.srvpgm</li>
<li>/samples/lib32/libSample2.a</li>
<li>/samples/lib32/libSample2.so</li>
<li>/QOpenSys/samples/lib/SAMPLE2.srvpgm</li>
<li>/QOpenSys/samples/lib/libSample2.a</li>
<li>/QOpenSys/samples/lib/libSample2.so</li>
</ol>
<p><span class="keyword">i5/OS</span> loads the
first candidate in the list that actually exists into the JVM as a native
method library. Even though candidates like '/qsys.lib/libSample2.a' and '/qsys.lib/libSample2.so'
occur in the search, it is not possible to create integrated file system files
or symbolic links in the /qsys.lib directories. Therefore, even though <span class="keyword">i5/OS</span> checks for these candidate
files, it will never find them in integrated file system directories that
begin with /qsys.lib.</p>
<p>However, you can create arbitrary symbolic links
from other integrated file system directories to <span class="keyword">i5/OS</span> objects
in the QSYS file system. As a result, valid file candidates include files
such as /home/user1/lib32/sample2.srvpgm. </p>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="rzahapaseexmplsmain.htm" title="The iSeries Java virtual machine (JVM) supports the use of native methods running in the i5/OS PASE environment. Prior to V5R2, the native iSeries JVM used only ILE native methods.">IBM i5/OS PASE native methods for Java</a></div>
</div>
<div class="relconcepts"><strong>Related concepts</strong><br />
<div><a href="rzahapasejavaenvvariables.htm" title="The Java virtual machine (JVM) uses the following variables to start i5/OS PASE environments. You need to set the QIBM_JAVA_PASE_STARTUP variable in order to run the IBM i5/OS PASE native method for Java example.">Java i5/OS PASE environment variables</a></div>
<div><a href="rzahapaseerrors.htm" title="To help you troubleshoot i5/OS PASE native methods, this topic describes error conditions that are indicated by i5/OS job log messages and Java runtime exceptions. The following lists describe errors that you may encounter at start up or at run time when using i5/OS PASE native methods for Java.">Java i5/OS PASE error codes</a></div>
<div><a href="rzahapaseexmpls.htm" title="The IBM i5/OS PASE native method for Java example calls an instance of a native C method that then uses Java Native Interface (JNI) to call back into Java code. Rather than accessing the string directly from Java code, the example calls a native method that then calls back into Java through JNI to get the string value.">Example: IBM i5/OS PASE native method for Java</a></div>
</div>
</div>
</body>
</html>