Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 19 additions & 6 deletions src/main/java/org/usb4java/Loader.java
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,11 @@ private static String extractLibrary(final String platform,
* times. Duplicate calls are ignored. This method is automatically called
* when the {@link LibUsb} class is loaded. When you need to do it earlier
* (To catch exceptions for example) then simply call this method manually.
* <p/>
* If the system property <tt>org.usb4java.LibraryName</tt> is defined, then
* instead of going through the classpath looking for the appropriate DLL,
* extracting it, etc., we simply call {@link System#loadLibrary}, passing
* in the value of the property.
*
* @throws LoaderException
* When loading the native wrapper libraries failed.
Expand All @@ -313,13 +318,21 @@ public static synchronized void load()
}

loaded = true;
final String platform = getPlatform();
final String lib = getLibName();
final String extraLib = getExtraLibName();
if (extraLib != null)
final String libraryName = System.getProperty("org.usb4java.LibraryName");
if (libraryName != null)
{
System.load(extractLibrary(platform, extraLib));
System.loadLibrary(libraryName);
}
else
{
final String platform = getPlatform();
final String lib = getLibName();
final String extraLib = getExtraLibName();
if (extraLib != null)
{
System.load(extractLibrary(platform, extraLib));
}
System.load(extractLibrary(platform, lib));
}
System.load(extractLibrary(platform, lib));
}
}