/** Puts library to temp dir and loads to memory */ private static void loadLib(String name) { Path sourcePath = Paths.get(LIBPATH, name); try { Path libPath = Files.copy(sourcePath, tempPath, StandardCopyOption.REPLACE_EXISTING); System.load(libPath.toString()); } catch (IOException e) { e.printStackTrace(); } }
private static void extractAndLoadNativeLib(String nativeLibName, Path target) { // System.err.println("loading "+nativeLibName); final Path path = Paths.get(target.toString(), nativeLibName); if (!path.toFile().exists()) { try (InputStream is = CudaEngine.class .getClassLoader() .getResourceAsStream("/lib/" + nativeLibName)) { // TODO TK property for lib dir Files.copy(is, path); } catch (IOException e) { e.printStackTrace(); } catch (NullPointerException e) { // TODO find a way to do it instead of eclipse final Path eclipsePath = FileSystems.getDefault().getPath("lib", nativeLibName); try { Files.copy(eclipsePath, path); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } } System.load(path.toString()); // System.load(nativeLibName); }