ca.weblite.nativeutils
Class NativeUtils
java.lang.Object
ca.weblite.nativeutils.NativeUtils
public class NativeUtils
- extends Object
Simple library class for working with JNI (Java Native Interface)
- Author:
- Adam Heirnich , http://www.adamh.cz
- See Also:
http://frommyplayground.com/how-to-load-native-jni-library-from-jar
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
loadLibraryFromJar
public static void loadLibraryFromJar(String path)
throws IOException
- Throws:
IOException
loadLibraryFromJar
public static void loadLibraryFromJar(String path,
Class source)
throws IOException
- Loads library from current JAR archive
The file from JAR is copied into system temporary directory and then loaded. The temporary file is deleted after exiting.
Method uses String as filename because the pathname is "abstract", not system-dependent.
- Parameters:
filename - The filename inside JAR as absolute path (beginning with '/'), e.g. /package/File.ext
- Throws:
IOException - If temporary file creation or read/write operation fails
IllegalArgumentException - If source file (param path) does not exist
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)).
loadFileFromJar
public static File loadFileFromJar(String path,
Class source)
throws IOException
- Throws:
IOException
Copyright © 2012–2014 Web Lite Solutions Corp.. All rights reserved.