public class NativeUtil
extends java.lang.Object
A simple library class which helps with loading dynamic libraries stored in the JAR archive. These libraries usualy contain implementation of some methods in native code (using JNI - Java Native Interface).
http://adamheinrich.com/blog/2012/how-to-load-native-jni-library-from-jar
https://github.com/adamheinrich/native-utils
Modifier and Type | Method and Description |
---|---|
static void |
loadLibraryFromJar(java.lang.String path)
Loads library from current JAR archive
The file from JAR is copied into system temporary directory and then loaded.
|
public static void loadLibraryFromJar(java.lang.String path) throws java.io.IOException
path
- The filename inside JAR as absolute path (beginning with '/'), e.g. /package/File.extjava.io.IOException
- If temporary file creation or read/write operation failsjava.lang.IllegalArgumentException
- If source file (param path) does not existjava.lang.IllegalArgumentException
- If the path is not absolute or if the filename is shorter than three characters (restriction of File.createTempFile(java.lang.String, java.lang.String)
).