code: private Throwable findProperNativeLib(SearchOrder _order, String _libName, String[] _searchPathes) {
          String arch = System.getProperty("os.arch");
          Throwable lastErr = null;
  
          if (_order == SearchOrder.SYSTEM_PATH) { // search in system pathes (e.g. content of LD_LIBRARY_PATH)
          	lastErr = loadSystemLib(_libName);
              if (lastErr == null) {
                  return null;
              }
  
          } else if (_order == SearchOrder.CLASS_PATH) {
              for (String path : _searchPathes) {
                  // first, try with OS architecture in path name
                  String fileNameWithPath = SystemUtil.concatFilePath(false, path, arch, _libName);
                  InputStream libAsStream = NativeLibraryLoader.class.getClassLoader().getResourceAsStream(fileNameWithPath);
                  lastErr = loadFromStream(fileNameWithPath, libAsStream);
                  if (lastErr == null) {
                      return null;
                  } else { // then try without OS architecture in path name
  
                      fileNameWithPath = SystemUtil.concatFilePath(false, path, _libName);
                      libAsStream = NativeLibraryLoader.class.getClassLoader().getResourceAsStream(fileNameWithPath);
                      lastErr = loadFromStream(fileNameWithPath, libAsStream);
                      if (lastErr == null) {
                          return null;
                      }
                  }
              }
          } else { // search in custom pathes
  
              for (String path : _searchPathes) {
                  File file = new File(SystemUtil.concatFilePath(false, path, arch, _libName));
                  if (!file.exists()) { // file not exists in file system, go to next entry
                      continue;
                  }
                  lastErr = loadLib(file.getAbsolutePath());
                  if (lastErr == null) {
                      return null;
                  }
              }
              lastErr = new IOException("No library in custom path found.");
          }
  
          return lastErr;
      }
docs: Tries to load a library from the given search path, depending on given {@link SearchOrder} value.
  
  @param _order search order option
  @param _libName name of the library
  @param _searchPathes pathes to search for library
  @return {@link Throwable} if loading fails, null if loading was successful