private static void loadLibraryResource(String resourceSubdirectoryName,String libraryName,String tempSubdirectoryName,String... dependentLibraryNames) throws Throwable {
  for (  String dependentLibraryName : dependentLibraryNames) {
    logger.log(level,"Library " + libraryName + " depends on "+ dependentLibraryName);
    String dependentResourceSubdirectoryName=resourceSubdirectoryName + "/" + osString()+ "/"+ archString();
    String dependentLibraryTempSubDirectoryName=libraryName + "_dependents" + File.separator+ osString()+ File.separator+ archString()+ File.separator;
    loadLibraryResource(dependentResourceSubdirectoryName,dependentLibraryName,dependentLibraryTempSubDirectoryName);
  }
  String libraryFileName=createLibraryFileName(libraryName);
  File libraryTempFile=createTempFile(tempSubdirectoryName,libraryFileName);
  if (!libraryTempFile.exists()) {
    String libraryResourceName=resourceSubdirectoryName + "/" + libraryFileName;
    logger.log(level,"Writing resource  " + libraryResourceName);
    logger.log(level,"to temporary file " + libraryTempFile);
    writeResourceToFile(libraryResourceName,libraryTempFile);
  }
  logger.log(level,"Loading library " + libraryTempFile);
  System.load(libraryTempFile.toString());
  logger.log(level,"Loading library " + libraryTempFile + " DONE");
}

private static void loadLibraryResource ( String resourceSubdirectoryName , String libraryName , String tempSubdirectoryName , String ... dependentLibraryNames ) throws Throwable { for ( String dependentLibraryName : dependentLibraryNames ) { logger . log ( level , "Library " + libraryName + " depends on " + dependentLibraryName ) ; String dependentResourceSubdirectoryName = resourceSubdirectoryName + "/" + osString ( ) + "/" + archString ( ) ; String dependentLibraryTempSubDirectoryName = libraryName + "_dependents" + File . separator + osString ( ) + File . separator + archString ( ) + File . separator ; loadLibraryResource ( dependentResourceSubdirectoryName , dependentLibraryName , dependentLibraryTempSubDirectoryName ) ; } String libraryFileName = createLibraryFileName ( libraryName ) ; File libraryTempFile = createTempFile ( tempSubdirectoryName , libraryFileName ) ; if ( ! libraryTempFile . exists ( ) ) { String libraryResourceName = resourceSubdirectoryName + "/" + libraryFileName ; logger . log ( level , "Writing resource  " + libraryResourceName ) ; logger . log ( level , "to temporary file " + libraryTempFile ) ; writeResourceToFile ( libraryResourceName , libraryTempFile ) ; } logger . log ( level , "Loading library " + libraryTempFile ) ; System . load ( libraryTempFile . toString ( ) ) ; logger . log ( level , "Loading library " + libraryTempFile + " DONE" ) ; }
load the library with the given name from a resource .
