diff --git a/src/main/java/org/usb4java/Loader.java b/src/main/java/org/usb4java/Loader.java index 3706e44..8d8339a 100644 --- a/src/main/java/org/usb4java/Loader.java +++ b/src/main/java/org/usb4java/Loader.java @@ -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. + *

+ * If the system property org.usb4java.LibraryName 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. @@ -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)); } }