com.jacob.com
Class LibraryLoader

java.lang.Object
  extended by com.jacob.com.LibraryLoader

public final class LibraryLoader
extends Object

Utility class to centralize the way in which the jacob JNI library is loaded.

This supports defining the path or library name using system properties or a custom resource file. If desired, jacob can auto-detect the correct version of the DLL for 32 or 64 bit windows, as long as you have named them differently.

  1. If system property JACOB_DLL_PATH is defined, the file located there will be loaded as the jacob dll using System.load().
  2. If system property JACOB_DLL_NAME is defined, the file located there will be loaded as the jacob dll.
  3. If system property JACOB_DLL_NAME_X86 and JACOB_DLL_NAME_X64 are defined, the file located there will be loaded as the jacob dll, depending on the version of Windows.
  4. If JACOB_DLL_NAME is defined in the com.jacob.com.JacobLibraryLoader resource file, the specified dll will be loaded from the java.library.path.
  5. If JACOB_DLL_NAME_X86 and JACOB_DLL_NAME_X64 are defined in the com.jacob.com.JacobLibraryLoader resource file, the specified dll will be loaded from the java.library.path, depending on the version of Windows.
  6. If none of the above are true, the default is to load the library named "jacob-<version>-<arch>" (or "jacob-<version>-<arch&rt;.dll") from the java.library.path.
The standard behavior for most applications is that LoadLibrary() will be called to load the dll. LoadLibary() searches directories specified in the variable java.library.path. This is why most test cases specify -Djava.library.path in their command line arguments.

JACOB_DLL_PATH submitted sourceforge ticket 1493647 Added 1.11
JACOB_DLL_NAME, JACOB_DLL_NAME_32, JACOB_DLL_NAME_64 submitted sourceforge ticket 1845039 Added 1.14M7

Author:
Scott Dickerson (sjd78), Jason Smith

Field Summary
static String DLL_NAME_MODIFIER_32_BIT
          Appended to "jacob" when building DLL name This string must EXACTLY match the string in the build.xml file
static String DLL_NAME_MODIFIER_64_BIT
          Appended to "jacob" when building DLL name This string must EXACTLY match the string in the build.xml file
static String JACOB_DLL_NAME
          Name of system property (currently jacob.dll.name) that may contain an alternate name for the JNI library (default is 'jacob').
static String JACOB_DLL_NAME_X64
          Name of system property (currently jacob.dll.name) that may contain an alternate name for the JNI library (default is 'jacob'), 64 bit windows.
static String JACOB_DLL_NAME_X86
          Name of system property (currently jacob.dll.name) that may contain an alternate name for the JNI library (default is 'jacob'), 32 bit windows.
static String JACOB_DLL_PATH
          Name of system property (currently jacob.dll.path) that may contain an absolute path to the JNI library.
 
Constructor Summary
LibraryLoader()
           
 
Method Summary
static String getPreferredDLLName()
          Developer note: This method MUST be synchronized with the DLL names created as part of the build process in build.xml
static void loadJacobLibrary()
          Load the jacob dll either from an absolute path or by a library name, both of which may be defined in various ways.
protected static boolean shouldLoad32Bit()
          Detects whether this is a 32-bit JVM.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

JACOB_DLL_PATH

public static final String JACOB_DLL_PATH
Name of system property (currently jacob.dll.path) that may contain an absolute path to the JNI library.

See Also:
Constant Field Values

JACOB_DLL_NAME

public static final String JACOB_DLL_NAME
Name of system property (currently jacob.dll.name) that may contain an alternate name for the JNI library (default is 'jacob').

See Also:
Constant Field Values

JACOB_DLL_NAME_X86

public static final String JACOB_DLL_NAME_X86
Name of system property (currently jacob.dll.name) that may contain an alternate name for the JNI library (default is 'jacob'), 32 bit windows.

See Also:
Constant Field Values

JACOB_DLL_NAME_X64

public static final String JACOB_DLL_NAME_X64
Name of system property (currently jacob.dll.name) that may contain an alternate name for the JNI library (default is 'jacob'), 64 bit windows.

See Also:
Constant Field Values

DLL_NAME_MODIFIER_32_BIT

public static final String DLL_NAME_MODIFIER_32_BIT
Appended to "jacob" when building DLL name This string must EXACTLY match the string in the build.xml file

See Also:
Constant Field Values

DLL_NAME_MODIFIER_64_BIT

public static final String DLL_NAME_MODIFIER_64_BIT
Appended to "jacob" when building DLL name This string must EXACTLY match the string in the build.xml file

See Also:
Constant Field Values
Constructor Detail

LibraryLoader

public LibraryLoader()
Method Detail

loadJacobLibrary

public static void loadJacobLibrary()
Load the jacob dll either from an absolute path or by a library name, both of which may be defined in various ways.

Throws:
UnsatisfiedLinkError - if the library does not exist.

getPreferredDLLName

public static String getPreferredDLLName()
Developer note: This method MUST be synchronized with the DLL names created as part of the build process in build.xml

The DLL name is "jacob\.release"

Returns:
the preferred name of the DLL adjusted for this platform and version without the ".dll" extension

shouldLoad32Bit

protected static boolean shouldLoad32Bit()
Detects whether this is a 32-bit JVM.

Returns:
true if this is a 32-bit JVM.


http://jacob-project.sourceforge.net