/** * Delegate the calling to {@link System#load(String)} or {@link System#loadLibrary(String)}. * @param libName - The native library path or name * @param absolute - Whether the native library will be loaded by path or by name */ public static void loadLibrary(String libName, boolean absolute) { if (absolute) { System.load(libName); } else { System.loadLibrary(libName); } }
public static void load(String filename) { System.load(filename); }
/** * Delegate the calling to {@link System#load(String)} or {@link System#loadLibrary(String)}. * @param libName - The native library path or name * @param absolute - Whether the native library will be loaded by path or by name */ public static void loadLibrary(String libName, boolean absolute) { if (absolute) { System.load(libName); } else { System.loadLibrary(libName); } }
public static void load(String filename) { System.load(filename); }
/** * Delegate the calling to {@link System#load(String)} or {@link System#loadLibrary(String)}. * @param libName - The native library path or name * @param absolute - Whether the native library will be loaded by path or by name */ public static void loadLibrary(String libName, boolean absolute) { if (absolute) { System.load(libName); } else { System.loadLibrary(libName); } }
/** @return null if the file was extracted and loaded. */ private Throwable loadFile (String sourcePath, String sourceCrc, File extractedFile) { try { System.load(extractFile(sourcePath, sourceCrc, extractedFile).getAbsolutePath()); return null; } catch (Throwable ex) { return ex; } }
/** * Load a native library of snappy-java */ private synchronized static void loadNativeLibrary() { if (!isLoaded) { try { nativeLibFile = findNativeLibrary(); if (nativeLibFile != null) { // Load extracted or specified snappyjava native library. System.load(nativeLibFile.getAbsolutePath()); } else { // Load preinstalled snappyjava (in the path -Djava.library.path) System.loadLibrary("snappyjava"); } } catch (Exception e) { e.printStackTrace(); throw new SnappyError(SnappyErrorCode.FAILED_TO_LOAD_NATIVE_LIBRARY, e.getMessage()); } isLoaded = true; } }
private boolean loadLibrary (String sharedLibName) { if (sharedLibName == null) return false; String path = extractLibrary(sharedLibName); if (path != null) System.load(path); return path != null; }
static boolean load(final String libName, final StringBuffer message) { try { if (libName.indexOf(SEPARATOR) != -1) { System.load(libName); } else { System.loadLibrary(libName); } return true; } catch (UnsatisfiedLinkError e) { if (message.length() == 0) { message.append(DELIMITER); } message.append('\t'); message.append(e.getMessage()); message.append(DELIMITER); } return false; }
/** @return null if the file was extracted and loaded. */ private Throwable loadFile (String sourcePath, String sourceCrc, File extractedFile) { try { System.load(extractFile(sourcePath, sourceCrc, extractedFile).getAbsolutePath()); return null; } catch (Throwable ex) { return ex; } }
private boolean loadLibrary (String sharedLibName) { if (sharedLibName == null) return false; String path = extractLibrary(sharedLibName); if (path != null) System.load(path); return path != null; }
/** * Utilizes the regular system call to attempt to load a native library. If a failure occurs, * then the function extracts native .so library out of the app's APK and attempts to load it. * <p/> * <strong>Note: This is a synchronous operation</strong> */ @SuppressLint("UnsafeDynamicallyLoadedCode") //intended fallback of System#loadLibrary() static void loadLibrary(Context context) { synchronized (ReLinker.class) { final File workaroundFile = unpackLibrary(context); System.load(workaroundFile.getAbsolutePath()); } }
public static void load(String libPath) { if (mLoaded.contains(libPath)) { return; } File libFile; try { libFile = getResourceAsFile(libPath); } catch (BrutException ex) { throw new UnsatisfiedLinkError(ex.getMessage()); } System.load(libFile.getAbsolutePath()); }
private static void loadLib(String path, String name) { name = System.mapLibraryName(name); // extends name with .dll, .so or .dylib try { InputStream in = ACWrapper.class.getResourceAsStream("/"+path + name); File fileOut = new File("your lib path"); OutputStream out = FileUtils.openOutputStream(fileOut); IOUtils.copy(in, out); in.close(); out.close(); System.load(fileOut.toString());//loading goes here } catch (Exception e) { //handle } }
public static void loadJarDll(String name) throws IOException { InputStream in = MyClass.class.getResourceAsStream(name); byte[] buffer = new byte[1024]; int read = -1; File temp = File.createTempFile(name, ""); FileOutputStream fos = new FileOutputStream(temp); while((read = in.read(buffer)) != -1) { fos.write(buffer, 0, read); } fos.close(); in.close(); System.load(temp.getAbsolutePath()); }
private static void load(File tmp, String arch) throws IOException { InputStream is = SjkWinHelper.class.getClassLoader().getResourceAsStream("sjkwinh.prop"); Properties prop = new Properties(); prop.load(is); String dllName = "sjkwinh" + arch + "." + prop.getProperty("dll" + arch + ".hash") + ".dll"; int len = Integer.valueOf(prop.getProperty("dll" + arch + ".len")); File tgt = new File(tmp, dllName); if (tgt.isFile() && tgt.length() == len) { // dll is present } else { tgt.delete(); InputStream dllis = SjkWinHelper.class.getClassLoader().getResourceAsStream("sjkwinh" + arch + ".dll"); byte[] buf = new byte[len]; int n = dllis.read(buf); if (n != buf.length) { throw new RuntimeException("Failed extract dll, size mismatch"); } FileOutputStream fos = new FileOutputStream(tgt); fos.write(buf); fos.close(); } System.load(tgt.getPath()); }
/** Extracts the source file and calls System.load. Attemps to extract and load from multiple locations. Throws runtime * exception if all fail. */ private void loadFile (String sourcePath) { String sourceCrc = crc(readFile(sourcePath)); String fileName = new File(sourcePath).getName(); // Temp directory with username in path. File file = new File(System.getProperty("java.io.tmpdir") + "/libgdx" + System.getProperty("user.name") + "/" + sourceCrc, fileName); Throwable ex = loadFile(sourcePath, sourceCrc, file); if (ex == null) return; // System provided temp directory. try { file = File.createTempFile(sourceCrc, null); if (file.delete() && loadFile(sourcePath, sourceCrc, file) == null) return; } catch (Throwable ignored) { } // User home. file = new File(System.getProperty("user.home") + "/.libgdx/" + sourceCrc, fileName); if (loadFile(sourcePath, sourceCrc, file) == null) return; // Relative directory. file = new File(".temp/" + sourceCrc, fileName); if (loadFile(sourcePath, sourceCrc, file) == null) return; // Fallback to java.library.path location, eg for applets. file = new File(System.getProperty("java.library.path"), sourcePath); if (file.exists()) { System.load(file.getAbsolutePath()); return; } throw new GdxRuntimeException(ex); }
/** Extracts the source file and calls System.load. Attemps to extract and load from multiple locations. Throws runtime * exception if all fail. */ private void loadFile (String sourcePath) { String sourceCrc = crc(readFile(sourcePath)); String fileName = new File(sourcePath).getName(); // Temp directory with username in path. File file = new File(System.getProperty("java.io.tmpdir") + "/libgdx" + System.getProperty("user.name") + "/" + sourceCrc, fileName); Throwable ex = loadFile(sourcePath, sourceCrc, file); if (ex == null) return; // System provided temp directory. try { file = File.createTempFile(sourceCrc, null); if (file.delete() && loadFile(sourcePath, sourceCrc, file) == null) return; } catch (Throwable ignored) { } // User home. file = new File(System.getProperty("user.home") + "/.libgdx/" + sourceCrc, fileName); if (loadFile(sourcePath, sourceCrc, file) == null) return; // Relative directory. file = new File(".temp/" + sourceCrc, fileName); if (loadFile(sourcePath, sourceCrc, file) == null) return; // Fallback to java.library.path location, eg for applets. file = new File(System.getProperty("java.library.path"), sourcePath); if (file.exists()) { System.load(file.getAbsolutePath()); return; } throw new GdxRuntimeException(ex); }
public static void init () { if (initialized) return; // Need to initialize bullet before using it. if (Gdx.app.getType() == ApplicationType.Desktop && customDesktopLib != null) { System.load(customDesktopLib); } else Bullet.init(); Gdx.app.log("Bullet", "Version = " + LinearMath.btGetVersion()); initialized = true; }
tinker.getLoadReporter().onLoadFileMd5Mismatch(library, ShareConstants.TYPE_LIBRARY); } else { System.load(patchLibraryPath); TinkerLog.i(TAG, "loadLibraryFromTinker success:" + patchLibraryPath); return true;