Class NativeUtil
java.lang.Object
com.github.weisj.darklaf.nativeutil.NativeUtil
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).
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic voidloadLibraryFromJar(Class<?> loaderClass, String path, String identifier) Loads library from current JAR archivestatic voidloadLibraryFromJarWithExtraResources(Class<?> loaderClass, String path, List<NativeUtil.Resource> resources, String identifier) Loads library from current JAR archive
-
Field Details
-
NATIVE_FOLDER_PATH_PREFIX
- See Also:
-
-
Method Details
-
loadLibraryFromJarWithExtraResources
public static void loadLibraryFromJarWithExtraResources(Class<?> loaderClass, String path, List<NativeUtil.Resource> resources, String identifier) throws IOException Loads library from current JAR archiveThe 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:
loaderClass- the class to use for loading.path- The path of file inside JAR as absolute path (beginning with '/'), e.g. /package/File.extidentifier- The library identifier for clean-up purposes- Throws:
IOException- If temporary file creation or read/write operation failsIllegalArgumentException- If source file (param path) does not existIllegalArgumentException- If the path is not absolute or if the filename is shorter than three characters (restriction ofFile.createTempFile(java.lang.String, java.lang.String)).FileNotFoundException- If the file could not be found inside the JAR.
-
loadLibraryFromJar
public static void loadLibraryFromJar(Class<?> loaderClass, String path, String identifier) throws IOException Loads library from current JAR archiveThe 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:
loaderClass- the class to use for loading.path- The path of file inside JAR as absolute path (beginning with '/'), e.g. /package/File.extidentifier- The library identifier for clean-up purposes- Throws:
IOException- If temporary file creation or read/write operation failsIllegalArgumentException- If source file (param path) does not existIllegalArgumentException- If the path is not absolute or if the filename is shorter than three characters (restriction ofFile.createTempFile(java.lang.String, java.lang.String)).FileNotFoundException- If the file could not be found inside the JAR.
-