The JavaTM Tutorial
Previous Page Lesson Contents Start of Tutorial > Start of Trail > Start of Lesson Search
Feedback Form

Trail: Java Native Interface
Lesson: Writing a Java Program with Native Methods

Creating and Loading Shared Libraries

Procedures for creating and loading shared libraries are platform dependent. This page provides some answers regarding naming conventions for shared libraries and locating shared libraries.

Naming Conventions

Each Java runtime environment provides a platform-dependent mechanism for mapping between the actual file name of a shared library and the name string that you pass as an argument to the System.loadLibrary method.

Search Mechanisms

Each Java runtime environment provides its own mechanism that indicates where to find shared libraries for native method implementations. The platform-dependent wrapper script or application shell can use the appropriate mechanism to indicate where shared libraries are located.

Avoiding Name Conflicts

To avoid file name conflicts, it is best to prepend directories or folders containing shared libraries to search paths, such as the LD_LIBRARY_PATH or PATH environment variables.

Supporting Multiple Platforms

Because a Java application with native methods may support multiple platforms, it helps to organize multiple shared libraries into sub-directories by platform, such as <app-dir>/lib/<platform>.
Previous Page Lesson Contents Start of Tutorial > Start of Trail > Start of Lesson Search
Feedback Form