List of usage examples for java.lang System loadLibrary
@CallerSensitive public static void loadLibrary(String libname)
From source file:Main.java
private static boolean loadLibrary(String Name) { boolean result = true; Log.d(TAG, "Trying to load library " + Name); try {// ww w . jav a2 s. c o m System.loadLibrary(Name); Log.d(TAG, "OpenCV libs init was ok!"); } catch (UnsatisfiedLinkError e) { Log.d(TAG, "Cannot load library \"" + Name + "\""); e.printStackTrace(); result &= false; } return result; }
From source file:Main.java
static void loadNativeLibrary() { synchronized (nativeLibraryLoadLock) { if (!nativeLibraryLoaded) { try { System.loadLibrary("MDWUtil"); nativeLibraryLoaded = true; } catch (Exception e) { System.err.println("Cannot load MDWUtil shared library"); }// www. j a va 2s. c o m } } }
From source file:Main.java
public static void loadAudioLib() { System.loadLibrary(GNUSTL_SHARED_LIB_NAME); System.loadLibrary(AV_UTIL_56_LIB_NAME); System.loadLibrary(AV_SWRESAMPLE_1_LIB_NAME); System.loadLibrary(AV_CODEC_56_LIB_NAME); System.loadLibrary(AV_FORMAT_56_LIB_NAME); // System.loadLibrary(AV_FILTER_LIB_NAME); // System.loadLibrary(AV_DEVICE_LIB_NAME); System.loadLibrary(SWSCALE_LIB_NAME); System.loadLibrary(AUDIO_PLAYER_LIB_NAME); }
From source file:com.yandex.sample.metrica.Stuff.java
public static void loadNativePart() { try {//from w w w . jav a2 s . c o m System.loadLibrary(Stuff.NATIVE_LIBRARY_MODULE); } catch (Throwable error) { Log.w(Stuff.LOG_TAG, Stuff.NATIVE_LIBRARY_PROBLEMS_HINT); } }
From source file:com.thenairn.linker.config.Libraries.java
public static void load() { try {//w ww .j a v a 2 s . co m logger.info("Loading DLL"); System.loadLibrary(getName()); logger.info("DLL is loaded from memory"); } catch (UnsatisfiedLinkError e) { loadFromJar(); } }
From source file:org.dmlc.xgboost4j.util.Initializer.java
/** * load native library, this method will first try to load library from java.library.path, then try to load library in jar package. * @param libName// www .java2s . c o m * @throws IOException */ private static void smartLoad(String libName) throws IOException { addNativeDir(nativePath); try { System.loadLibrary(libName); } catch (UnsatisfiedLinkError e) { try { NativeUtils.loadLibraryFromJar(nativeResourcePath + System.mapLibraryName(libName)); } catch (IOException e1) { throw e1; } } }
From source file:eu.riscoss.RemoteRiskAnalyserMain.java
static void loadJSmile() throws Exception { File dir = new File(FileUtils.getTempDirectory(), "jnativelibs-" + RandomStringUtils.randomAlphabetic(30)); if (!dir.mkdir()) { throw new Exception("failed to make dir"); }// w ww . j a v a2 s . co m File jsmile = new File(dir, "libjsmile.so"); URL jsmURL = Thread.currentThread().getContextClassLoader().getResource("libjsmile.so"); FileUtils.copyURLToFile(jsmURL, jsmile); System.setProperty("java.library.path", System.getProperty("java.library.path") + ":" + dir.getAbsolutePath()); // flush the library paths Field sysPathsField = ClassLoader.class.getDeclaredField("sys_paths"); sysPathsField.setAccessible(true); sysPathsField.set(null, null); // Check that it works... System.loadLibrary("jsmile"); dir.deleteOnExit(); jsmile.deleteOnExit(); }
From source file:org.cryptomator.jni.JniModule.java
@Provides @Singleton//w ww.j a v a2s. com public Optional<MacFunctions> macFunctions(Lazy<MacFunctions> macFunctions) { if (SystemUtils.IS_OS_MAC_OSX) { try { System.loadLibrary(MacFunctions.LIB_NAME); LOG.info("loaded {}", System.mapLibraryName(MacFunctions.LIB_NAME)); return Optional.of(macFunctions.get()); } catch (UnsatisfiedLinkError e) { LOG.error("Could not load JNI lib {} from path {}", System.mapLibraryName(MacFunctions.LIB_NAME), System.getProperty("java.library.path")); } } return Optional.empty(); }
From source file:kyotocabinet.Loader.java
/** * Load the native library./*w w w. j ava 2 s. com*/ */ static synchronized void load() { if (loaded) { return; } String lib = System.mapLibraryName("jkyotocabinet"); if (lib.endsWith(".dll")) { // lib?lib URL url = Loader.class.getClassLoader().getResource(System.mapLibraryName("jkyotocabinet")); String libFileName = "./temp" + File.separatorChar + System.mapLibraryName("jkyotocabinet"); File file = new File(libFileName); try { FileUtils.copyURLToFile(url, file); } catch (IOException e) { throw new RuntimeException(e); } System.load(file.getAbsolutePath()); } else { System.loadLibrary("jkyotocabinet"); } loaded = true; }
From source file:cc.recommenders.nativelibs.NativeLibLoader.java
public void loadLibrary(String library) { try {/*from w ww. j a va 2 s.co m*/ String fileName = copyLibraryToTempFile(library); System.load(fileName); } catch (IOException e) { System.err.println("Could not find library " + library + " as resource, trying fallback lookup through System.loadLibrary"); System.loadLibrary(library); } }