|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.netlib.utils.JNIMethods
public final class JNIMethods
Static helper methods for dealing with the Java Native Interface and detection of operating systems and architectures. The main purpose of this class is to provide a more portable alternative to the System.loadLibrary method (and horrible syntax of Bundle-NativeCode in MANIFEST files) when bundling binaries as part of a jar (either inside, or in a directory structure nearby).
Note on usage: unfortunately it is not possible to provide a loadLibrary(String) method here as it needs to know the calling class, which is lost when wrapped here. To load a native library using this class, call the getPortableLibraryName() method to return a String which may then be passed to System.loadLibrary().
Note: due to the nature of this class, a portable JUnit TestCase is not possible.
Nested Class Summary | |
---|---|
static class |
JNIMethods.ARCHType
Enumeration of common CPU architectures. |
static class |
JNIMethods.OSType
Enumeration of common operating systems, independent of version or architecture. |
Field Summary | |
---|---|
static JNIMethods.ARCHType |
ARCH
Stores the CPU Architecture the JVM is currently running on. |
static JNIMethods.OSType |
OS
Stores the operating system the JVM is currently running on. |
Constructor Summary | |
---|---|
JNIMethods()
|
Method Summary | |
---|---|
static java.lang.String |
getPortableLibraryName(java.lang.String name)
The System.mapLibraryName method is broken in the sense that it does not give unique names for operating systems and architectures. |
static void |
main(java.lang.String[] args)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final JNIMethods.ARCHType ARCH
public static final JNIMethods.OSType OS
Constructor Detail |
---|
public JNIMethods()
Method Detail |
---|
public static java.lang.String getPortableLibraryName(java.lang.String name)
The resulting filename will be constructed by forcing the library name to lowercase and appending an extra String that is defined by the operating system (the architecture is only encoded if it is relevant). Some examples are for the parameter 'name':-
name
-
java.lang.IllegalArgumentException
- if the input name is zero length or contains a directory separator
character.public static void main(java.lang.String[] args)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |