Package com.tagtraum.core
Class NativeLibraryLoader
- java.lang.Object
-
- com.tagtraum.core.NativeLibraryLoader
-
public final class NativeLibraryLoader extends Object
First tries to load a library the default way usingSystem.loadLibrary(String)
, upon failure falls back to the base directory of the given class package or the jar the class is in. This way, a native library is found, if it located in the same directory as a particular jar, identified by a specific class from that jar.- Author:
- Hendrik Schreiber
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
findFile(String name, Class baseClass, FileFilter filter)
Finds a file that is either in the classpath or in the same directory as a given class's jar.static void
loadLibrary(String libName, Class<?> baseClass)
Loads a library.
-
-
-
Method Detail
-
loadLibrary
public static void loadLibrary(String libName, Class<?> baseClass)
Loads a library.- Parameters:
libName
- name of the library, as described inSystem.loadLibrary(String)
);baseClass
- class that identifies the jar
-
findFile
public static String findFile(String name, Class baseClass, FileFilter filter) throws FileNotFoundException
Finds a file that is either in the classpath or in the same directory as a given class's jar.- Parameters:
name
- (partial) filenamebaseClass
- base classfilter
- filter that determines whether a file is a match- Returns:
- file
- Throws:
FileNotFoundException
- if a matching file cannot be found
-
-