Java Dynamic Management Kit 3.2 Programming Guide
[ Previous ][ Fast Back ]Chapter 14. M-Let, Bootstrap and Launcher Services[ Fast Forward ][ Next ]

Using the Library Loading Service

The m-let and bootstrap class loaders implement the findLibrary() method of the ClassLoader class, to allow the loading of dynamic native libraries from a .jar file. The basic operation of the services is described in Library Loaders in Chapter 12.

Default Temporary Library Directory

The m-let and bootstrap class loaders use a temporary directory to store the library files before they are loaded into memory. The default temporary library directory depends on the operating environment.

Operating Environment

Default Temporary Library Directory

Solaris

installDir/SUNWconn/jaw/tmp

Windows NT

installDir\SUNWconn\jaw\tmp

Changing the Temporary Library Directory

If you want the m-let and bootstrap class loaders to use a temporary library directory other than the default, you can specify the new directory by invoking the setLibraryDirectory() method.

Example 14-11 shows how to use the setLibraryDirectory() method to change the temporary library directory. In this example, the m-let and bootstrap class loaders will store the library files in the /home/libs directory.

Example 14-11. Using setLibraryDirectory() to Change the Temporary Library Directory
mletSrv.setLibraryDirectory("/home/libs");

Loading a Library From a .jar File

Example 14-12 shows an example hierarchy for the libraries in a .jar file.

Example 14-12. Library Hierarchy in a .jar File
/SunOS/sparc/5.7/lib/libA.so
/SunOS/sparc/5.7/lib/libB.so
\WindowsNT\x86\4.0\lib\B.dll

An m-bean must invoke the System.loadLibrary() method to load a native library from a .jar file. Example 14-13 shows code for loading libraries from a .jar file.

Example 14-13. Loading a Library From a .jar File
System.loadLibrary("A");
// loads /libA.so

System.loadLibrary("B");

// loads /SunOS/sparc/5.7/lib/libB.so
// if the agent runs on Solaris 7

// loads \WindowsNT\x86\4.0\lib\B.dll
// if the agent runs on Windows NT 4.0


[ Previous ][ Home ][ Next ]
Bootstrap Service[ Up ]Security Manager