Class NativeUtils

java.lang.Object
io.opentimeline.NativeUtils

public class NativeUtils
extends java.lang.Object
A simple library class which helps with loading dynamic libraries stored in the JAR archive. These libraries usually contain implementation of some methods in native code (using JNI - Java Native Interface).
See Also:
http://adamheinrich.com/blog/2012/how-to-load-native-jni-library-from-jar, https://github.com/adamheinrich/native-utils
  • Field Summary

    Fields 
    Modifier and Type Field Description
    static java.lang.String NATIVE_FOLDER_PATH_PREFIX  
  • Method Summary

    Modifier and Type Method 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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Method Details

    • loadLibraryFromJar

      public static void loadLibraryFromJar​(java.lang.String path) throws java.io.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:
      path - The path of file inside JAR as absolute path (beginning with '/'), e.g. /package/File.ext
      Throws:
      java.io.IOException - If temporary file creation or read/write operation fails
      java.lang.IllegalArgumentException - If source file (param path) does not exist
      java.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)).
      java.io.FileNotFoundException - If the file could not be found inside the JAR.