/** * Find the right shared library, depending on the operating system and architecture. * * @throws UnsupportedOperationException Throw an exception if no native library for this platform * was found. */ private static URL findLibraryResource(final String libraryFileName) { String osName = System.getProperty("os.name").toLowerCase(); String osArch = System.getProperty("os.arch").toLowerCase(); String resourceName = null; if (osName.startsWith(OS_WIN)) { resourceName = determineWindowsLibrary(libraryFileName, osName, osArch); } else if (osName.startsWith(OS_LINUX)) { resourceName = determineLinuxLibrary(libraryFileName, osName, osArch); } else if (osName.startsWith(OS_FREEBSD)) { resourceName = determineFreebsdLibrary(libraryFileName, osName, osArch); } else if (osName.startsWith(OS_MAC)) { resourceName = determineMacLibrary(libraryFileName); } else { unsupportedPlatform(osName, osArch); } URL resource = NativeLoader.class.getResource(resourceName); if (null == resource) { unsupportedPlatform(osName, osArch, resourceName); } return resource; }