Class NativeLibraries


  • public final class NativeLibraries
    extends Object
    Helper class for loading native libraries. The methods in this class search for the library binary in some more directories than those specified in the java.library.path system property.

    The searched directories are:

    • the "native library path" as returned by getNativeLibraryPath(), which is the directory ../native/<arch>-<os>/ relative to the JAR file of this library, where <arch> stands for your processor architecture and <os> for the operating system.

      Possible values for <arch> include:

      • arm64
      • x86_64
      • x86

      Possible values for <os> include:

      • linux
      • windows
      • macosx
      • freebsd
      • netbsd
      • openbsd
    • the same directory as the JAR file of this library

    Standard usage is by calling the method loadLibrary(java.lang.String) with the library name, or use Classes.makeExtendedURLClassLoader() and Classes.ClassLoaderBuilder.setCustomLookupNativeLibraries(java.util.function.Predicate) if third-party code loads the library.