List of usage examples for java.lang System load
@CallerSensitive public static void load(String filename)
From source file:fr.fastconnect.factory.tibco.bw.maven.AbstractBWMojo.java
protected boolean initHawk(boolean failIfNotFound) throws BinaryMissingException { if (tibcoRvHomePath == null || !tibcoRvHomePath.exists()) { if (failIfNotFound) { throw new BinaryMissingException(HAWK_BINARY_NOTFOUND); } else {/*from w w w. j av a2 s . c o m*/ getLog().info("Unable to init Hawk."); return false; } } File tibrvj; if (SystemUtils.IS_OS_WINDOWS) { getLog().debug("Windows OS"); tibcoRvHomePath = new File(tibcoRvHomePath, "bin/"); tibrvj = new File(tibcoRvHomePath, "tibrvj.dll"); System.load(tibrvj.getAbsolutePath()); } else { getLog().debug("Not Windows OS"); tibcoRvHomePath = new File(tibcoRvHomePath, "lib/"); String osArch = System.getProperty("os.arch"); tibrvj = null; if (osArch.equals("x86")) { getLog().debug("x86"); tibrvj = new File(tibcoRvHomePath, "libtibrvj.so"); System.loadLibrary("tibrvj"); } else if (osArch.contains("64")) { getLog().debug("64"); tibrvj = new File(tibcoRvHomePath, "libtibrvj64.so"); System.loadLibrary("tibrvj64"); } } getLog().debug("Loading system library : " + tibrvj.getAbsolutePath()); return true; }
From source file:com.example.gangzhang.myapplication.VideoPlayerActivity.java
private void load() { String LIB_ROOT = Vitamio.getLibraryPath(); System.load(LIB_ROOT + "libcom_example_gangzhang_myapplication_VideoPlayerActivity.so"); }
From source file:imageviewer.system.ImageViewerClient.java
private void verifyJAI() { // JAI Detection boolean dllPassFlag = false; try {/*from w ww . j av a 2 s. c o m*/ Class.forName("javax.media.jai.JAI"); } catch (ClassNotFoundException exc) { JFrame frame = new JFrame("mii imageviewer"); JOptionPane.showMessageDialog(frame, "JAI is not installed on this machine. Please install."); exc.printStackTrace(); System.exit(1); } // JAI DLL Detection try { System.load(System.getProperty("java.home") + "/bin/mlib_jai.dll"); dllPassFlag = true; } catch (Exception exc) { dllPassFlag = false; } catch (UnsatisfiedLinkError exc22) { dllPassFlag = false; } // Don't ever check for *.so objects! Breaks things on Linux! -gsw if (dllPassFlag == false) { LOG.error("Missing JAI DLL or system libraries."); } else { LOG.info("Java Advanced Imaging (JAI) version: " + JAI.getBuildVersion()); } }
From source file:com.max2idea.android.fwknop.Fwknop.java
private void loadNativeLib(String lib, String destDir) { if (true) {/*www . j a v a2 s .c o m*/ String libLocation = destDir + "/" + lib; try { System.load(libLocation); } catch (Exception ex) { Log.e("JNIExample", "failed to load native library: " + ex); } } }
From source file:com.att.aro.core.util.Util.java
/** * Load the JNI library directly by using the file name * /* www .j av a2s . c o m*/ * @param filename * @param targetLibFolder */ public static boolean loadLibrary(String filename, String targetLibFolder) { try { System.load(targetLibFolder + File.separator + filename); return true; } catch (Exception e) { return false; } }
From source file:pl.edu.icm.visnow.system.main.VisNow.java
private void loadNativeLibraries() { LOGGER.info("Initializing native libraries..."); String libDir = getOperatingFolder(); LOGGER.info(" os.name: " + System.getProperty("os.name")); LOGGER.info(" os.arch: " + System.getProperty("os.arch")); boolean isLinux = (getOsType() == OsType.OS_LINUX); boolean isWindows = (getOsType() == OsType.OS_WINDOWS); boolean is64 = VisNow.isCpuArch64(); boolean devel = isDevelopment(); String sep = File.separator; if (!isLinux && !isWindows) { LOGGER.warn(" native libraries not found (you should use Linux or Windows)"); return;/*from w ww .j av a2 s . c om*/ } if (devel) { libDir += sep + "dist" + sep + "lib" + sep + "native"; } else { libDir += sep + "lib" + sep + "native"; } if (!(new File(libDir)).exists()) { LOGGER.warn(" native libraries directory not found"); return; } if (isLinux && (new File(libDir + sep + "linux")).exists()) { libDir += sep + "linux"; if (is64) { libDir += sep + "x86_64"; } else { libDir += sep + "x86"; } } else if (isWindows && (new File(libDir + sep + "windows")).exists()) { libDir += sep + "windows"; if (is64) { libDir += sep + "win64"; } else { libDir += sep + "win32"; } } if (debug) { LOGGER.info("Native library directory: " + libDir); } File nativeLibDir = new File(libDir); if (!nativeLibDir.exists()) { LOGGER.warn(" native libraries directory not found"); return; } String string = " Loading native shared library for "; if (isLinux) { string += "Linux "; } else if (isWindows) { string += "Windows "; } if (is64) { string += "64-bit"; } else if (isWindows) { string += "32-bit"; } string += "."; LOGGER.info(string); String[] nativeLibraries = nativeLibDir.list(); for (String lib : nativeLibraries) { File libF = new File(libDir + sep + lib); if (!libF.isDirectory()) { LOGGER.debug(lib + " is not a directory, ommiting!"); continue; } String[] libraryFiles = libF.list(new FilenameFilter() { public boolean accept(File dir, String name) { return (name.toLowerCase().endsWith(".dll") || name.toLowerCase().endsWith(".so")); } }); ArrayList<String> libsToRead = new ArrayList<String>(); for (int i = 0; i < libraryFiles.length; i++) { libsToRead.add(libDir + sep + lib + sep + libraryFiles[i]); } //try readining libraries with possible dependencies until success //WARNING: loop dependency is not supported int fails = 0; while (!libsToRead.isEmpty()) { String libToRead = libsToRead.get(0); libsToRead.remove(libToRead); try { System.load(libToRead); fails = 0; } catch (UnsatisfiedLinkError err) { libsToRead.add(libToRead); fails++; } if (fails > 0 && fails == libsToRead.size()) break; } if (libsToRead.isEmpty()) { LOGGER.info("Loaded " + lib + " native library."); loadedNativeLibraries.add(lib); } else { String failMessage = "Loading " + lib + " failed:"; for (int i = 0; i < libsToRead.size(); i++) { failMessage += " cannot read " + libsToRead.get(i) + ";"; } LOGGER.warn(failMessage); } } }
From source file:com.microsoft.tfs.jni.loader.NativeLoader.java
/** * Loads a native library from a directory. * * @param libraryName/* w w w . j a v a2 s. co m*/ * the library name (short name, not including extension or "lib" * prefix). Not null or empty. * @param directory * the path to the directory (not null). * @param osgiOperatingSystem * the OSGI-style operating system name to match resources on (not * null or empty). * @param osgiArchitecture * the OSGI-style architecture name. May be null or empty to omit the * architecture string from the resource path during the search. Mac * OS X uses "fat" shared libraries that support multiple * architectures, and would omit this parameter. * @throws UnsatisfiedLinkError * if a library that maps to the given library name cannot be found. */ private static void loadLibraryFromDirectory(final String libraryName, final String directory, final String osgiOperatingSystem, final String osgiArchitecture) { Check.notNullOrEmpty(libraryName, "libraryName"); //$NON-NLS-1$ Check.notNull(directory, "directory"); //$NON-NLS-1$ Check.notNull(osgiOperatingSystem, "osgiOperatingSystem"); //$NON-NLS-1$ final File libraryDirectory = new File(directory); if (libraryDirectory.exists() == false) { throw new UnsatisfiedLinkError(MessageFormat.format("Native library base directory {0} does not exist", //$NON-NLS-1$ libraryDirectory.getAbsolutePath())); } if (libraryDirectory.isDirectory() == false) { throw new UnsatisfiedLinkError( MessageFormat.format("Native library base directory {0} is not a directory", //$NON-NLS-1$ libraryDirectory.getAbsolutePath())); } /* * Compute the subdirectory (i.e. "linux/ppc") inside the base * directory. */ File fullDirectory = new File(libraryDirectory, osgiOperatingSystem); if (osgiArchitecture != null && osgiArchitecture.length() > 0) { fullDirectory = new File(fullDirectory, osgiArchitecture); } /* * Convert "fun" into "libfun.so" or "fun.dll" or whatever, depending on * platform. * * Oracle broke mapLibraryName on Java 7 so that it returns * libname.dylib instead of libname.jnilib. (System.loadLibrary * continues to use .jnilib, however, so this wasn't a change of the * expected extension, it's just broken.) So we need to transform names * ourselves on Mac OS. */ final String mappedLibraryName; if (Platform.isCurrentPlatform(Platform.MAC_OS_X)) { mappedLibraryName = "lib" + libraryName + ".jnilib"; //$NON-NLS-1$ //$NON-NLS-2$ } else { mappedLibraryName = System.mapLibraryName(libraryName); } /* * Construct the full path. */ final File fullLibraryFile = new File(fullDirectory, mappedLibraryName); if (fullLibraryFile.exists() == false) { throw new UnsatisfiedLinkError(MessageFormat.format("Native library file {0} does not exist", //$NON-NLS-1$ fullLibraryFile.getAbsolutePath())); } if (fullLibraryFile.isDirectory() == true) { throw new UnsatisfiedLinkError(MessageFormat.format("Native library file {0} is a directory", //$NON-NLS-1$ fullLibraryFile.getAbsolutePath())); } log.debug( MessageFormat.format("Trying to load native library file {0}", fullLibraryFile.getAbsolutePath())); //$NON-NLS-1$ System.load(fullLibraryFile.getAbsolutePath()); log.debug(MessageFormat.format("Loaded {0} from user-specified directory", //$NON-NLS-1$ fullLibraryFile.getAbsolutePath())); return; }
From source file:com.peterbochs.PeterBochsDebugger.java
public static void main(String[] args) { WebServiceUtil.log("peter-bochs", "start", null, null, null); try {/*w w w . j a v a2 s . co m*/ UIManager.setLookAndFeel("com.peterswing.white.PeterSwingWhiteLookAndFeel"); } catch (Exception e) { e.printStackTrace(); } if (args.length == 0) { String errorMessage = "Wrong number of argument\n\n"; errorMessage += "\nIn Linux/Mac : java -jar peter-bochs-debugger.jar bochs -f bochsrc.bxrc"; errorMessage += "\nIn windows : java -jar peter-bochs-debugger.jar c:\\program files\\bochs2.4.3\\bochsdbg.exe -q -f bochsrc.bxrc"; errorMessage += "\n!!! if using peter-bochs in windows, you need to pass the full path of bochs exe and -q to the parameter. (!!! relative path of bochs exe will not work)"; errorMessage += "\n!!! to use \"experimental feature\", please add \"-debug\" to the parameter list"; System.out.println(errorMessage); JOptionPane.showMessageDialog(null, errorMessage); System.exit(1); } else { if (args[0].equals("-version") || args[0].equals("-v")) { System.out.println(Global.version); System.exit(1); } } for (String str : args) { if (str.contains("bochsrc") || str.contains(".bxrc")) { bochsrc = str; } } String osName = System.getProperty("os.name").toLowerCase(); if (osName.toLowerCase().contains("windows")) { os = OSType.win; } else if (osName.toLowerCase().contains("mac")) { os = OSType.mac; } else { os = OSType.linux; } if (os == OSType.mac) { com.apple.eawt.Application macApp = com.apple.eawt.Application.getApplication(); // System.setProperty("dock:name", "Your Application Name"); macApp.setDockIconImage(new ImageIcon( PeterBochsDebugger.class.getClassLoader().getResource("com/peterbochs/icons/peter.png")) .getImage()); // java.awt.PopupMenu menu = new java.awt.PopupMenu(); // menu.add(new MenuItem("test")); // macApp.setDockMenu(menu); macApp.addApplicationListener(new MacAboutBoxHandler()); } if (ArrayUtils.contains(args, "-debug")) { Global.debug = true; args = (String[]) ArrayUtils.removeElement(args, "-debug"); } else { Global.debug = false; } try { if (PeterBochsDebugger.class.getProtectionDomain().getCodeSource().getLocation().getFile() .endsWith(".jar")) { JarFile jarFile = new JarFile( PeterBochsDebugger.class.getProtectionDomain().getCodeSource().getLocation().getFile()); if (System.getProperty("os.name").toLowerCase().contains("linux")) { if (System.getProperty("os.arch").contains("64")) { if (Global.debug) { System.out.println("Loading linux 64 bits jogl"); } CommonLib.writeFile( jarFile.getInputStream( new JarEntry("com/peterbochs/jogl_dll/linux_amd64/libgluegen-rt.so")), new File("libgluegen-rt.so")); CommonLib.writeFile( jarFile.getInputStream( new JarEntry("com/peterbochs/jogl_dll/linux_amd64/libjogl_awt.so")), new File("libjogl_awt.so")); CommonLib.writeFile( jarFile.getInputStream( new JarEntry("com/peterbochs/jogl_dll/linux_amd64/libjogl_cg.so")), new File("libjogl_cg.so")); CommonLib.writeFile( jarFile.getInputStream( new JarEntry("com/peterbochs/jogl_dll/linux_amd64/libjogl.so")), new File("libjogl.so")); } else { if (Global.debug) { System.out.println("Loading linux 32 bits jogl"); } CommonLib.writeFile( jarFile.getInputStream( new JarEntry("com/peterbochs/jogl_dll/linux_i586/libgluegen-rt.so")), new File("libgluegen-rt.so")); CommonLib.writeFile( jarFile.getInputStream( new JarEntry("com/peterbochs/jogl_dll/linux_i586/libjogl_awt.so")), new File("libjogl_awt.so")); CommonLib.writeFile( jarFile.getInputStream( new JarEntry("com/peterbochs/jogl_dll/linux_i586/libjogl_cg.so")), new File("libjogl_cg.so")); CommonLib.writeFile( jarFile.getInputStream( new JarEntry("com/peterbochs/jogl_dll/linux_i586/libjogl.so")), new File("libjogl.so")); } try { File f = new File("."); Runtime.getRuntime().load(f.getAbsolutePath() + File.separator + "libjogl.so"); System.out.println("Loading " + f.getAbsolutePath() + File.separator + "libjogl.so"); Runtime.getRuntime().load(f.getAbsolutePath() + File.separator + "libjogl_awt.so"); Runtime.getRuntime().load(f.getAbsolutePath() + File.separator + "libjogl_cg.so"); Runtime.getRuntime().load(f.getAbsolutePath() + File.separator + "libgluegen-rt.so"); } catch (UnsatisfiedLinkError e) { e.printStackTrace(); System.err.println("Native code library failed to load.\n" + e); System.err.println( "Solution : Please add \"-Djava.library.path=.\" to start peter-bochs\n" + e); } } else if (System.getProperty("os.name").toLowerCase().contains("windows")) { CommonLib.writeFile(jarFile.getInputStream(new JarEntry("com/peterbochs/exe/PauseBochs.exe")), new File("PauseBochs.exe")); CommonLib.writeFile(jarFile.getInputStream(new JarEntry("com/peterbochs/exe/StopBochs.exe")), new File("StopBochs.exe")); CommonLib.writeFile(jarFile.getInputStream(new JarEntry("com/peterbochs/exe/ndisasm.exe")), new File("ndisasm.exe")); if (System.getProperty("os.arch").contains("64")) { if (Global.debug) { System.out.println("Loading windows 64 bits jogl"); } CommonLib.writeFile( jarFile.getInputStream( new JarEntry("com/peterbochs/jogl_dll/windows_amd64/jogl.dll")), new File("jogl.dll")); CommonLib.writeFile( jarFile.getInputStream( new JarEntry("com/peterbochs/jogl_dll/windows_amd64/jogl_awt.dll")), new File("jogl_awt.dll")); CommonLib.writeFile( jarFile.getInputStream( new JarEntry("com/peterbochs/jogl_dll/windows_amd64/jogl_cg.dll")), new File("jogl_cg.dll")); CommonLib.writeFile( jarFile.getInputStream( new JarEntry("com/peterbochs/jogl_dll/windows_amd64/gluegen-rt.dll")), new File("gluegen-rt.dll")); } else { if (Global.debug) { System.out.println("Loading windows 32 bits jogl"); } CommonLib.writeFile( jarFile.getInputStream( new JarEntry("com/peterbochs/jogl_dll/windows_i586/jogl.dll")), new File("jogl.dll")); CommonLib.writeFile( jarFile.getInputStream( new JarEntry("com/peterbochs/jogl_dll/windows_i586/jogl_awt.dll")), new File("jogl_awt.dll")); CommonLib.writeFile( jarFile.getInputStream( new JarEntry("com/peterbochs/jogl_dll/windows_i586/jogl_cg.dll")), new File("jogl_cg.dll")); CommonLib.writeFile( jarFile.getInputStream( new JarEntry("com/peterbochs/jogl_dll/windows_i586/gluegen-rt.dll")), new File("gluegen-rt.dll")); } try { File f = new File("."); System.load(f.getAbsolutePath() + File.separator + "jogl.dll"); System.load(f.getAbsolutePath() + File.separator + "jogl_awt.dll"); System.load(f.getAbsolutePath() + File.separator + "jogl_cg.dll"); System.load(f.getAbsolutePath() + File.separator + "gluegen-rt.dll"); } catch (UnsatisfiedLinkError e) { e.printStackTrace(); System.err.println("Native code library failed to load.\n" + e); System.err.println( "Solution : Please add \"-Djava.library.path=.\" to start peter-bochs\n" + e); } } } } catch (IOException e) { e.printStackTrace(); } if (ArrayUtils.contains(args, "-loadBreakpoint")) { Setting.getInstance().setLoadBreakpointAtStartup(true); args = (String[]) ArrayUtils.removeElement(args, "-loadBreakpoint"); } else if (ArrayUtils.contains(args, "-loadbreakpoint")) { Setting.getInstance().setLoadBreakpointAtStartup(true); args = (String[]) ArrayUtils.removeElement(args, "-loadbreakpoint"); } for (int x = 0; x < args.length; x++) { if (args[x].toLowerCase().startsWith("-osdebug")) { Global.osDebug = CommonLib.string2long(args[x].replaceAll("-.*=", "")); args = (String[]) ArrayUtils.removeElement(args, args[x]); x = -1; } else if (args[x].toLowerCase().startsWith("-profilingmemoryport")) { Global.profilingMemoryPort = (int) CommonLib.string2long(args[x].replaceAll("-.*=", "")); args = (String[]) ArrayUtils.removeElement(args, args[x]); x = -1; } else if (args[x].toLowerCase().startsWith("-profilingjmpport")) { Global.profilingJmpPort = (int) CommonLib.string2long(args[x].replaceAll("-.*=", "")); args = (String[]) ArrayUtils.removeElement(args, args[x]); x = -1; } else if (args[x].toLowerCase().startsWith("-loadelf")) { Global.elfPaths = args[x].replaceAll("-loadelf=", "").split(","); Setting.getInstance().setLoadSystemMapAtStartup(true); args = (String[]) ArrayUtils.removeElement(args, args[x]); x = -1; } else if (args[x].toLowerCase().startsWith("-loadmap")) { System.out.println("-loadmap is not deprecated, please use -loadelf."); } } arguments = args; SwingUtilities.invokeLater(new Runnable() { public void run() { PeterBochsDebugger inst = new PeterBochsDebugger(); PeterBochsDebugger.instance = inst; new Thread("preventSetVisibleHang thread") { public void run() { try { Thread.sleep(10000); if (preventSetVisibleHang) { System.out.println( "setVisible(true) cause system hang, this probably a swing bug, so force exit, please restart"); System.exit(-1); } } catch (InterruptedException e) { e.printStackTrace(); } } }.start(); if (Global.debug) { System.out.println("setVisible(true)"); } inst.setVisible(true); preventSetVisibleHang = false; if (Global.debug) { System.out.println("end setVisible(true)"); } } }); }
From source file:com.android.wfds.printservice.WPrintService.java
private static synchronized void loadLibraries(ApplicationInfo appInfo) { if (!mLibrariesLoaded) { if (((appInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0) || ((appInfo.flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0)) { System.loadLibrary("wfdscrypto"); System.loadLibrary("wfdsssl"); System.loadLibrary("wfdsjpeg"); System.loadLibrary("wfdspng"); System.loadLibrary("wfdscups"); System.loadLibrary("wfds"); } else {/*from ww w. j a v a 2 s . c om*/ System.load(Environment.getRootDirectory() + "/lib/libwfdscrypto.so"); System.load(Environment.getRootDirectory() + "/lib/libwfdsssl.so"); System.load(Environment.getRootDirectory() + "/lib/libwfdsjpeg.so"); System.load(Environment.getRootDirectory() + "/lib/libwfdspng.so"); System.load(Environment.getRootDirectory() + "/lib/libwfdscups.so"); System.load(Environment.getRootDirectory() + "/lib/libwfds.so"); } mLibrariesLoaded = true; } }
From source file:org.opennms.install.Installer.java
/** * <p>loadLibrary</p>/*w ww. j a v a 2s . c o m*/ * * @param path a {@link java.lang.String} object. * @return a boolean. */ public boolean loadLibrary(final String path) { try { System.out.print(" - trying to load " + path + ": "); System.load(path); System.out.println("OK"); return true; } catch (final UnsatisfiedLinkError ule) { System.out.println("NO"); } return false; }