Package org.libheiffx

Class NativeUtils

java.lang.Object
org.libheiffx.NativeUtils

public class NativeUtils extends 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:
  • Field Details

  • Method Details

    • loadLibraryFromJar

      public static String[] loadLibraryFromJar(String tempDir, String... path) 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:
      tempDir - Directory where to place the lib files. On OSX it is no longer allowed to use the temp directory by the system. Instat you have to specify the user directory or on linux the LD_LIBRARAY_PATH directory
      path - The path of file 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)).
      FileNotFoundException - If the file could not be found inside the JAR.