List of usage examples for java.lang System loadLibrary
@CallerSensitive public static void loadLibrary(String libname)
From source file:com.jeremydyer.nifi.CropImageProcessor.java
@Override protected void init(final ProcessorInitializationContext context) { final List<PropertyDescriptor> descriptors = new ArrayList<PropertyDescriptor>(); descriptors.add(X_POINT);/*from w w w .j a v a2 s . c om*/ descriptors.add(Y_POINT); descriptors.add(CROP_WIDTH); descriptors.add(CROP_HEIGHT); this.descriptors = Collections.unmodifiableList(descriptors); final Set<Relationship> relationships = new HashSet<Relationship>(); relationships.add(REL_ORIGINAL); relationships.add(REL_CROPPED_IMAGE); relationships.add(REL_FAILURE); this.relationships = Collections.unmodifiableSet(relationships); //Load the OpenCV Native Library System.loadLibrary(Core.NATIVE_LIBRARY_NAME); }
From source file:es.uma.lcc.lockpic.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.mainactivity); System.loadLibrary("jpg"); // load native libraries // This activity is able to open images directly from a file browser. // If this is the case, we store the path, which will be used in onPostCreate Intent intent = getIntent();/* w w w .ja va 2 s. c o m*/ if (Intent.ACTION_VIEW.equals(intent.getAction()) && intent.getType() != null && (savedInstanceState == null || savedInstanceState.getBoolean("firstTime", true))) { if (intent.getType().startsWith("image/")) { mDirectDecryptPath = LockPicIO.getPathFromIntent(MainActivity.this, intent); if (mDirectDecryptPath == null) Toast.makeText(this, R.string.unknownIntent, Toast.LENGTH_SHORT).show(); } } // disable screen capture getWindow().setFlags(LayoutParams.FLAG_SECURE, LayoutParams.FLAG_SECURE); }
From source file:com.jeremydyer.nifi.FaceDetectionProcessor.java
@Override protected void init(final ProcessorInitializationContext context) { final List<PropertyDescriptor> descriptors = new ArrayList<PropertyDescriptor>(); descriptors.add(FACE_CLASSIFIER);/*from w w w.j ava2 s .c o m*/ descriptors.add(LEFT_EYE_CLASSIFIER); descriptors.add(RIGHT_EYE_CLASSIFIER); this.descriptors = Collections.unmodifiableList(descriptors); final Set<Relationship> relationships = new HashSet<Relationship>(); relationships.add(REL_ORIGINAL); relationships.add(REL_OBJECT_DETECTED); relationships.add(REL_NO_OBJECT_DETECTED); relationships.add(REL_FAILURE); this.relationships = Collections.unmodifiableSet(relationships); //Load the OpenCV Native Library System.loadLibrary(Core.NATIVE_LIBRARY_NAME); }
From source file:com.xperia64.rompatcher.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); staticThis = MainActivity.this; setContentView(R.layout.main);/*from w w w . j a v a 2 s .c o m*/ // Load native libraries try { System.loadLibrary("apsn64patcher"); } catch (UnsatisfiedLinkError e) { Log.e("Bad:", "Cannot grab apspatcher!"); } try { System.loadLibrary("ipspatcher"); } catch (UnsatisfiedLinkError e) { Log.e("Bad:", "Cannot grab ipspatcher!"); } try { System.loadLibrary("ipspatcher"); } catch (UnsatisfiedLinkError e) { Log.e("Bad:", "Cannot grab ipspatcher!"); } try { System.loadLibrary("upspatcher"); } catch (UnsatisfiedLinkError e) { Log.e("Bad:", "Cannot grab upspatcher!"); } try { System.loadLibrary("xdelta3patcher"); } catch (UnsatisfiedLinkError e) { Log.e("Bad:", "Cannot grab xdelta3patcher!"); } try { System.loadLibrary("bpspatcher"); } catch (UnsatisfiedLinkError e) { Log.e("Bad:", "Cannot grab bpspatcher!"); } try { System.loadLibrary("bzip2"); } catch (UnsatisfiedLinkError e) { Log.e("Bad:", "Cannot grab bzip2!"); } try { System.loadLibrary("bsdiffpatcher"); } catch (UnsatisfiedLinkError e) { Log.e("Bad:", "Cannot grab bsdiffpatcher!"); } try { System.loadLibrary("ppfpatcher"); } catch (UnsatisfiedLinkError e) { Log.e("Bad:", "Cannot grab ppfpatcher!"); } try { System.loadLibrary("ips32patcher"); } catch (UnsatisfiedLinkError e) { Log.e("Bad:", "Cannot grab ips32patcher!"); } try { System.loadLibrary("glib-2.0"); } catch (UnsatisfiedLinkError e) { Log.e("Bad:", "Cannot grab glib-2.0!"); } try { System.loadLibrary("gmodule-2.0"); } catch (UnsatisfiedLinkError e) { Log.e("Bad:", "Cannot grab gmodule-2.0!"); } try { System.loadLibrary("edsio"); } catch (UnsatisfiedLinkError e) { Log.e("Bad:", "Cannot grab edsio!"); } try { System.loadLibrary("xdelta1patcher"); } catch (UnsatisfiedLinkError e) { Log.e("Bad:", "Cannot grab ips32patcher!"); } try { System.loadLibrary("ips32patcher"); } catch (UnsatisfiedLinkError e) { Log.e("Bad:", "Cannot grab ips32patcher!"); } try { System.loadLibrary("ecmpatcher"); } catch (UnsatisfiedLinkError e) { Log.e("Bad:", "Cannot grab ecmpatcher!"); } try { System.loadLibrary("dpspatcher"); } catch (UnsatisfiedLinkError e) { Log.e("Bad:", "Cannot grab dpspatcher!"); } try { System.loadLibrary("dldipatcher"); } catch (UnsatisfiedLinkError e) { Log.e("Bad:", "Cannot grab dldipatcher!"); } try { System.loadLibrary("xpcpatcher"); } catch (UnsatisfiedLinkError e) { Log.e("Bad:", "Cannot grab xpcpatcher!"); } try { System.loadLibrary("asarpatcher"); } catch (UnsatisfiedLinkError e) { Log.e("Bad:", "Cannot grab asarpatcher!"); } try { System.loadLibrary("asmpatcher"); } catch (UnsatisfiedLinkError e) { Log.e("Bad:", "Cannot grab asmpatcher!"); } c = (CheckBox) findViewById(R.id.backupCheckbox); d = (CheckBox) findViewById(R.id.altNameCheckbox); r = (CheckBox) findViewById(R.id.ignoreCRC); e = (CheckBox) findViewById(R.id.fileExtCheckbox); ed = (EditText) findViewById(R.id.txtOutFile); final Button romButton = (Button) findViewById(R.id.romButton); romButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Globals.mode = true; Intent intent = new Intent(staticThis, FileBrowserActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); startActivityForResult(intent, 1); } }); final Button patchButton = (Button) findViewById(R.id.patchButton); patchButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Globals.mode = false; Intent intent = new Intent(staticThis, FileBrowserActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); startActivityForResult(intent, 1); } }); final ImageButton bkHelp = (ImageButton) findViewById(R.id.backupHelp); bkHelp.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { AlertDialog dialog = new AlertDialog.Builder(staticThis).create(); dialog.setTitle(getResources().getString(R.string.bkup_rom)); dialog.setMessage(getResources().getString(R.string.bkup_rom_desc)); dialog.setCancelable(true); dialog.setButton(DialogInterface.BUTTON_POSITIVE, getResources().getString(android.R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int buttonId) { } }); dialog.show(); } }); final ImageButton altNameHelp = (ImageButton) findViewById(R.id.outfileHelp); altNameHelp.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { AlertDialog dialog = new AlertDialog.Builder(staticThis).create(); dialog.setTitle(getResources().getString(R.string.rename1)); dialog.setMessage(getResources().getString(R.string.rename_desc)); dialog.setCancelable(true); dialog.setButton(DialogInterface.BUTTON_POSITIVE, getResources().getString(android.R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int buttonId) { } }); dialog.show(); } }); final ImageButton chkHelp = (ImageButton) findViewById(R.id.ignoreHelp); chkHelp.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { AlertDialog dialog = new AlertDialog.Builder(staticThis).create(); dialog.setTitle(getResources().getString(R.string.ignoreChks)); dialog.setMessage(getResources().getString(R.string.ignoreChks_desc)); dialog.setCancelable(true); dialog.setButton(DialogInterface.BUTTON_POSITIVE, getResources().getString(android.R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int buttonId) { } }); dialog.show(); } }); InputFilter filter = new InputFilter() { public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) { for (int i = start; i < end; i++) { String IC = "*/*\n*\r*\t*\0*\f*`*?***\\*<*>*|*\"*:*"; if (IC.contains("*" + source.charAt(i) + "*")) { return ""; } } return null; } }; ed.setFilters(new InputFilter[] { filter }); c.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { if (((CheckBox) v).isChecked()) { d.setEnabled(true); if (d.isChecked()) { ed.setEnabled(true); e.setEnabled(true); } } else { d.setEnabled(false); ed.setEnabled(false); e.setEnabled(false); } } }); d.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { if (((CheckBox) v).isChecked()) { ed.setEnabled(true); e.setEnabled(true); } else { e.setEnabled(false); ed.setEnabled(false); } } }); final Button applyButton = (Button) findViewById(R.id.applyPatch); applyButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // Warn about patching archives. if (Globals.fileToPatch.toLowerCase(Locale.US).endsWith(".7z") || Globals.fileToPatch.toLowerCase(Locale.US).endsWith(".zip") || Globals.fileToPatch.toLowerCase(Locale.US).endsWith(".rar")) { AlertDialog dialog = new AlertDialog.Builder(staticThis).create(); dialog.setTitle(getResources().getString(R.string.warning)); dialog.setMessage(getResources().getString(R.string.zip_warning_desc)); dialog.setCancelable(false); dialog.setButton(DialogInterface.BUTTON_POSITIVE, getResources().getString(android.R.string.yes), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int buttonId) { patchCheck(); } }); dialog.setButton(DialogInterface.BUTTON_NEGATIVE, getResources().getString(android.R.string.cancel), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int buttonId) { Toast t = Toast.makeText(staticThis, getResources().getString(R.string.nopatch), Toast.LENGTH_SHORT); t.show(); } }); dialog.show(); } else { patchCheck(); } } }); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { // Uggh. requestPermissions(); } }
From source file:ca.psiphon.PsiphonTunnel.java
public synchronized boolean startRouting() throws Exception { // Load tun2socks library embedded in the aar // If this method is called more than once with the same library name, the second and subsequent calls are ignored. // http://docs.oracle.com/javase/7/docs/api/java/lang/Runtime.html#loadLibrary%28java.lang.String%29 System.loadLibrary("tun2socks"); return startVpn(); }
From source file:com.aps490.drdc.prototype.MainActivity.java
public static void initNativeLib(Context context) { try {// w w w . j av a2 s. c om // Try loading our native lib, see if it works... System.loadLibrary("libarchitect"); } catch (UnsatisfiedLinkError er) { ApplicationInfo appInfo = context.getApplicationInfo(); String libName = "libarchitect.so"; String destPath = context.getFilesDir().toString(); try { String soName = destPath + File.separator + libName; new File(soName).delete(); UnzipUtil.extractFile(appInfo.sourceDir, "lib/" + Build.CPU_ABI + "/" + libName, destPath); System.load(soName); } catch (IOException e) { // extractFile to app files dir did not work. Not enough space? Try elsewhere... destPath = context.getExternalCacheDir().toString(); // Note: location on external memory is not secure, everyone can read/write it... // However we extract from a "secure" place (our apk) and instantly load it, // on each start of the app, this should make it safer. String soName = destPath + File.separator + libName; new File(soName).delete(); // this copy could be old, or altered by an attack try { UnzipUtil.extractFile(appInfo.sourceDir, "lib/" + Build.CPU_ABI + "/" + libName, destPath); System.load(soName); } catch (IOException e2) { Log.e("AMMAR:", "Exception in InstallInfo.init(): " + e); e.printStackTrace(); } } } }
From source file:org.opennms.web.rest.v1.MeasurementsRestServiceITCase.java
protected static void assumeRrdtoolExists(final String libraryName) { final String libraryPath = System.getProperty("java.library.path", ""); if (!libraryPath.contains(":/usr/local/lib")) { System.setProperty("java.library.path", libraryPath + ":/usr/local/lib"); }// ww w . j a v a2 s.c o m boolean rrdtoolExists = false; try { final CommandLauncher cl = CommandLauncherFactory.createVMLauncher(); final Process p = cl.exec(new CommandLine(findRrdtool()), EnvironmentUtils.getProcEnvironment()); final int returnCode = p.waitFor(); LOG.debug("Loading library from java.library.path={}", System.getProperty("java.library.path")); System.loadLibrary(libraryName); rrdtoolExists = returnCode == 0; } catch (final Exception e) { LOG.warn("Failed to run 'rrdtool' or libjrrd(2)? is missing.", e); } Assume.assumeTrue(rrdtoolExists); }
From source file:com.mcreations.usb.windows.JavaxUsb.java
/** Load native library */ private static void loadLibrary() throws UsbException { if (libraryLoaded) return;/* w w w . j ava2 s.c o m*/ try { log(LOG_HOTPLUG, FUNC, CLASS, "loadLibrary", "Getting java.library.path"); // String temp = "java.library.path="+System.getProperty("java.library.path"); // System.out.println("java.library.path="+System.getProperty("java.library.path")); System.loadLibrary(LIBRARY_NAME); } catch (Exception e) { throw new UsbException(EXCEPTION_WHILE_LOADING_SHARED_LIBRARY + " <" + System.mapLibraryName(LIBRARY_NAME) + "> : \n" + e.getMessage()); } catch (Error e) { throw new UsbException(ERROR_WHILE_LOADING_SHARED_LIBRARY + " <" + System.mapLibraryName(LIBRARY_NAME) + "> : \n" + e.getMessage()); } }
From source file:org.apache.jk.apr.AprImpl.java
/** This method of loading the libs doesn't require setting * LD_LIBRARY_PATH. Assuming a 'right' binary distribution, * or a correct build all files will be in their right place. * * The burden is on our code to deal with platform specific * extensions and to keep the paths consistent - not easy, but * worth it if it avoids one extra step for the user. * * Of course, this can change to System.load() and putting the * libs in LD_LIBRARY_PATH./* w w w .java2 s .c o m*/ */ public void loadNative() throws Throwable { if (aprHome == null) aprHome = baseDir; // XXX Update for windows if (jniMode) { /* In JNI mode we use mod_jk for the native functions. This seems the cleanest solution that works with multiple VMs. */ if (jniModeSo.equals("inprocess")) { ok = true; return; } try { log.info("Loading " + jniModeSo); if (jniModeSo != null) System.load(jniModeSo); } catch (Throwable ex) { // ignore //ex.printStackTrace(); return; } ok = true; return; } /* jkjni _must_ be linked with apr and crypt - this seem the only ( decent ) way to support JDK1.4 and JDK1.3 at the same time try { System.loadLibrary( "crypt" ); } catch( Throwable ex ) { // ignore ex.printStackTrace(); } try { System.loadLibrary( "apr" ); } catch( Throwable ex ) { System.out.println("can't load apr, that's fine"); ex.printStackTrace(); } */ try { if (nativeSo == null) { // This will load libjkjni.so or jkjni.dll in LD_LIBRARY_PATH log.debug("Loading jkjni from " + System.getProperty("java.library.path")); System.loadLibrary("jkjni"); } else { System.load(nativeSo); } } catch (Throwable ex) { ok = false; //ex.printStackTrace(); throw ex; } }
From source file:org.apache.sysml.utils.NativeHelper.java
/** * Attempts to load native BLAS/*from w w w . java2 s . c o m*/ * * @param customLibPath can be null (if we want to only want to use LD_LIBRARY_PATH), else the * @param blas can be gomp, openblas or mkl_rt * @param optionalMsg message for debugging * @return true if successfully loaded BLAS */ private static boolean loadBLAS(String customLibPath, String blas, String optionalMsg) { // First attempt to load from custom library path if (customLibPath != null) { String libPath = customLibPath + File.separator + System.mapLibraryName(blas); try { System.load(libPath); // Print to stdout as this feature is intended for cloud environment System.out.println("Loaded the library:" + libPath); return true; } catch (UnsatisfiedLinkError e1) { // Print to stdout as this feature is intended for cloud environment System.out.println("Unable to load " + libPath + ":" + e1.getMessage()); } } // Then try loading using loadLibrary try { System.loadLibrary(blas); return true; } catch (UnsatisfiedLinkError e) { if (optionalMsg != null) LOG.debug("Unable to load " + blas + "(" + optionalMsg + "):" + e.getMessage()); else LOG.debug("Unable to load " + blas + ":" + e.getMessage()); return false; } }