public class Library
extends java.lang.Object
library.${name}.path
" System property is set to a directory,
subdirectories are searched:
${platform}/${arch}
"
${platform}
"
${os}
"
"
${name}-${version}
" library name if the version can be determined.
${name}
" library name
${name}${bit-model}-${version}
" library name if the version can be determined.
${name}-${version}
" library name if the version can be determined.
${name}
" library name
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.
META-INF/native/${platform}/${library[-version]}
": Store your library here if you want to embed more
than one platform JNI library in the jar.
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.
META-INF/native/${library[-version]}
": Store your library here if your JAR is only going to embedding one
platform library.
library.${name}.path
" System property (if set)
java.io.tmpdir
" System property)
${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 linuxSystem.mapLibraryName(String)
Modifier and Type | Field and Description |
---|---|
private java.lang.ClassLoader |
classLoader |
private boolean |
loaded |
private java.lang.String |
name |
private java.lang.String |
nativeLibraryPath |
private java.net.URL |
nativeLibrarySourceUrl |
(package private) static java.lang.String |
SLASH |
private java.lang.String |
version |
Constructor and Description |
---|
Library(java.lang.String name) |
Library(java.lang.String name,
java.lang.Class<?> clazz) |
Library(java.lang.String name,
java.lang.String version) |
Library(java.lang.String name,
java.lang.String version,
java.lang.ClassLoader classLoader) |
Modifier and Type | Method and Description |
---|---|
private void |
chmod755(java.io.File file) |
private static void |
close(java.io.Closeable file) |
private void |
doLoad() |
private java.io.File |
extract(java.util.ArrayList<java.lang.Throwable> errors,
java.net.URL source,
java.lang.String prefix,
java.lang.String suffix,
java.io.File directory) |
private boolean |
extractAndLoad(java.util.ArrayList<java.lang.Throwable> errors,
java.lang.String customPath,
java.lang.String dir,
java.lang.String libName,
java.lang.String targetLibName) |
private java.io.File |
file(java.lang.String... paths) |
java.lang.String |
getArchSpecifcResourcePath()
Deprecated.
|
java.lang.String |
getArchSpecificResourcePath() |
static int |
getBitModel() |
java.lang.String |
getLibraryFileName() |
java.lang.String |
getNativeLibraryPath()
Get the path to the native library loaded.
|
java.net.URL |
getNativeLibrarySourceUrl()
Get the URL to the native library source that has been extracted (if it was extracted).
|
static java.lang.String |
getOperatingSystem() |
java.lang.String |
getOperatingSystemSpecifcResourcePath()
Deprecated.
|
java.lang.String |
getOperatingSystemSpecificResourcePath() |
static java.lang.String |
getPlatform() |
java.lang.String |
getPlatformSpecifcResourcePath()
Deprecated.
|
java.lang.String |
getPlatformSpecifcResourcePath(java.lang.String platform)
Deprecated.
|
java.lang.String |
getPlatformSpecificResourcePath() |
java.lang.String |
getPlatformSpecificResourcePath(java.lang.String platform) |
java.lang.String |
getResorucePath()
Deprecated.
|
java.lang.String |
getResourcePath() |
java.lang.String[] |
getSpecificSearchDirs()
Search directories for library:
${platform}/${arch} to enable platform JNI library for different processor archs
${platform} to enable platform JNI library
${os} to enable OS JNI library
no directory
|
void |
load()
Load the native library.
|
private boolean |
load(java.util.ArrayList<java.lang.Throwable> errors,
java.io.File lib) |
private boolean |
loadLibrary(java.util.ArrayList<java.lang.Throwable> errors,
java.lang.String lib) |
private java.lang.String |
map(java.lang.String libName) |
private static java.lang.String |
version(java.lang.Class<?> clazz) |
static final java.lang.String SLASH
private final java.lang.String name
private final java.lang.String version
private final java.lang.ClassLoader classLoader
private boolean loaded
private java.lang.String nativeLibraryPath
private java.net.URL nativeLibrarySourceUrl
public Library(java.lang.String name)
public Library(java.lang.String name, java.lang.Class<?> clazz)
public Library(java.lang.String name, java.lang.String version)
public Library(java.lang.String name, java.lang.String version, java.lang.ClassLoader classLoader)
private static java.lang.String version(java.lang.Class<?> clazz)
public java.lang.String getNativeLibraryPath()
public java.net.URL getNativeLibrarySourceUrl()
public static java.lang.String getOperatingSystem()
public static java.lang.String getPlatform()
public static int getBitModel()
public void load()
private void doLoad()
@Deprecated public final java.lang.String getArchSpecifcResourcePath()
public final java.lang.String getArchSpecificResourcePath()
@Deprecated public final java.lang.String getOperatingSystemSpecifcResourcePath()
public final java.lang.String getOperatingSystemSpecificResourcePath()
@Deprecated public final java.lang.String getPlatformSpecifcResourcePath()
public final java.lang.String getPlatformSpecificResourcePath()
@Deprecated public final java.lang.String getPlatformSpecifcResourcePath(java.lang.String platform)
public final java.lang.String getPlatformSpecificResourcePath(java.lang.String platform)
@Deprecated public final java.lang.String getResorucePath()
public final java.lang.String getResourcePath()
public final java.lang.String getLibraryFileName()
public final java.lang.String[] getSpecificSearchDirs()
${platform}/${arch}
to enable platform JNI library for different processor archs${platform}
to enable platform JNI library${os}
to enable OS JNI libraryprivate boolean extractAndLoad(java.util.ArrayList<java.lang.Throwable> errors, java.lang.String customPath, java.lang.String dir, java.lang.String libName, java.lang.String targetLibName)
private java.io.File file(java.lang.String... paths)
private java.lang.String map(java.lang.String libName)
private java.io.File extract(java.util.ArrayList<java.lang.Throwable> errors, java.net.URL source, java.lang.String prefix, java.lang.String suffix, java.io.File directory)
private static void close(java.io.Closeable file)
private void chmod755(java.io.File file)
private boolean load(java.util.ArrayList<java.lang.Throwable> errors, java.io.File lib)
private boolean loadLibrary(java.util.ArrayList<java.lang.Throwable> errors, java.lang.String lib)