com.moesol.bindings
Class NativeLibraryFinder
java.lang.Object
com.moesol.bindings.NativeLibraryFinder
public class NativeLibraryFinder
- extends Object
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
OS_PREFIXES
public static String[] OS_PREFIXES
NativeLibraryFinder
public NativeLibraryFinder()
loadLibrary
public static void loadLibrary(Class classInJar,
String libraryName)
- Finds and loads a native library using several different
strategies. The default set of strategies tries to
find the native library using the following search:
- tries System.loadLibrary
- tries to find the library in the same directory as the jar.
If the URL to the jar is not the
file:
protocol this step is skipped.
- tries to find a library with the same name as the
jar file with the .jar extension removed.
This supports maven since maven will rename artifacts so
that the name of the jar file and native library will
include the version number. For example, on Windows a jar
file of
fobs4jmf-0.4.jar
will cause a search
for fobs4jmf-0.4.dll
- tries to find the library as a resource.
If found as a resource the native library is extracted to the
library directory property and loaded from there.
For both the file and resource searches it also searchs
for derivations based on the os, cpu architecture, and os version.
So on Windows a loadLibrary("foo")
looks for
{jar or classes directory}\foo.dll
{jar or classes directory}\Windows XP\x86\foo.dll
{jar or classes directory}\Windows XP\x86\5.1\foo.dll
{resource}/foo.dll
{resource}/Windows XP/x86/foo.dll
{resource}/Windows XP/x86/5.1/foo.dll
- Parameters:
classInJar
- a class that is in the jar to be locatedlibraryName
- name of library to load
getLibraryDirectory
public static File getLibraryDirectory()
setLibraryDirectory
public static void setLibraryDirectory(File libraryDirectory)
getStrategies
public static List getStrategies()
Copyright © 2004 Moebius Solutions, Inc. All Rights Reserved.