Class Library


  • public class Library
    extends Object
    Used to find and load a JNI library, eventually after having extracted it. It will search for the library in order at the following locations:
    1. in the custom library path: If the "library.${name}.path" System property is set to a directory, subdirectories are searched:
      1. "${platform}/${arch}"
      2. "${platform}"
      3. "${os}"
      4. ""
      for 2 namings of the library:
      1. as "${name}-${version}" library name if the version can be determined.
      2. as "${name}" library name
    2. system library path: This is where the JVM looks for JNI libraries by default.
      1. as "${name}${bit-model}-${version}" library name if the version can be determined.
      2. as "${name}-${version}" library name if the version can be determined.
      3. as "${name}" library name
    3. classpath path: If the JNI library can be found on the classpath, it will get extracted and then loaded. This way you can embed your JNI libraries into your packaged JAR files. They are looked up as resources in this order:
      1. "META-INF/native/${platform}/${arch}/${library[-version]}": Store your library here if you want to embed more than one platform JNI library on different processor archs in the jar.
      2. "META-INF/native/${platform}/${library[-version]}": Store your library here if you want to embed more than one platform JNI library in the jar.
      3. "META-INF/native/${os}/${library[-version]}": Store your library here if you want to embed more than one platform JNI library in the jar but don't want to take bit model into account.
      4. "META-INF/native/${library[-version]}": Store your library here if your JAR is only going to embedding one platform library.
      The file extraction is attempted until it succeeds in the following directories.
      1. The directory pointed to by the "library.${name}.path" System property (if set)
      2. a temporary directory (uses the "java.io.tmpdir" System property)
    where:
    • "${name}" is the name of library
    • "${version}" is the value of "library.${name}.version" System property if set. Otherwise it is set to the ImplementationVersion property of the JAR's Manifest
    • "${os}" is your operating system, for example "osx", "linux", or "windows"
    • "${bit-model}" is "64" if the JVM process is a 64 bit process, otherwise it's "32" if the JVM is a 32 bit process
    • "${arch}" is the architecture for the processor, for example "amd64" or "sparcv9"
    • "${platform}" is "${os}${bit-model}", for example "linux32" or "osx64"
    • "${library[-version]}": is the normal jni library name for the platform (eventually with -${version}) suffix. For example "${name}.dll" on windows, "lib${name}.jnilib" on OS X, and "lib${name}.so" on linux
    Author:
    Hiram Chirino
    See Also:
    System.mapLibraryName(String)