當前位置: 首頁>>代碼示例>>Java>>正文


Java NativeLibrary類代碼示例

本文整理匯總了Java中com.sun.jna.NativeLibrary的典型用法代碼示例。如果您正苦於以下問題:Java NativeLibrary類的具體用法?Java NativeLibrary怎麽用?Java NativeLibrary使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


NativeLibrary類屬於com.sun.jna包,在下文中一共展示了NativeLibrary類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: addWatch

import com.sun.jna.NativeLibrary; //導入依賴的package包/類
@Override public LKey addWatch(String path) throws IOException {
    // what if the file doesn't exist?
    int id = IMPL.inotify_add_watch(fd, path,
                InotifyImpl.IN_CREATE | InotifyImpl.IN_MOVED_TO |
                InotifyImpl.IN_DELETE | InotifyImpl.IN_MOVED_FROM |
                InotifyImpl.IN_MODIFY | InotifyImpl.IN_ATTRIB);
    //XXX handle error return value (-1)
    LOG.log(Level.FINEST, "addWatch{0} res: {1}", new Object[]{path, id});
    if (id <= 0) {
        // 28 == EINOSPC
        int errno = NativeLibrary.getInstance("c").getFunction("errno").getInt(0); // NOI18N
        throw new IOException("addWatch on " + path + " errno: " + errno); // NOI18N
    }

    LKey newKey = map.get(id);
    if (newKey == null) {
        newKey = new LKey(id, path);
        map.put(id, newKey);
    }
    return newKey;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:22,代碼來源:LinuxNotifier.java

示例2: Saitek

import com.sun.jna.NativeLibrary; //導入依賴的package包/類
public Saitek(File... libraryPath) {
  // try paths individually
  for (File f : libraryPath) {
    String path = f.toString();
    if (path.length() > 0) {
      // System.out.println("Using jna.library.path " + path);
      System.setProperty("jna.library.path", path);
    }
    try {
      NativeLibrary.getInstance(DirectOutputLibrary.JNA_LIBRARY_NAME);
      dol = (DirectOutputLibrary) Native.loadLibrary(DirectOutputLibrary.JNA_LIBRARY_NAME, DirectOutputLibrary.class);
    } catch (UnsatisfiedLinkError err) {
      System.err.println("Unable to load DirectOutput.dll from " + f + " (running on " + System.getProperty("os.name") + "-" + System.getProperty("os.version") 
              + "-" + System.getProperty("os.arch") + "\nContinuuing...");
      continue;
    }
    System.out.println("Loaded library from " + f);
    break;
  }
  if (dol == null) {
    throw new IllegalArgumentException("Unable to load DirectOutput.dll from the paths provided");
  }
  executor = Executors.newSingleThreadExecutor();
  executor.submit(this::init);
}
 
開發者ID:beders,項目名稱:saitek-lcd,代碼行數:26,代碼來源:Saitek.java

示例3: loadLibraryWithTiming

import com.sun.jna.NativeLibrary; //導入依賴的package包/類
private static NativeLibrary loadLibraryWithTiming(String name) {
	String successName = String.format("mr4c.loadlib.%s.success", name);
	String failureName = String.format("mr4c.loadlib.%s.failure", name);
	StatsTimer timer = new StatsTimer(
		MR4CStats.getClient(),
		successName,
		failureName
	);
	boolean success = false;
	try {
		NativeLibrary result = doLoadLibrary(name);
		success = true;
		return result;
	} finally {
		timer.done(success);
	}
}
 
開發者ID:google,項目名稱:mr4c,代碼行數:18,代碼來源:JnaUtils.java

示例4: loadNativeLibraries

import com.sun.jna.NativeLibrary; //導入依賴的package包/類
protected void loadNativeLibraries() {
	s_log.info("Begin loading native libraries");
	s_log.info("jna.library.path={}", System.getProperty("jna.library.path"));
	s_log.info("jna.platform.library.path={}", System.getProperty("jna.platform.library.path"));
	s_log.info("LD_LIBRARY_PATH={}", System.getenv("LD_LIBRARY_PATH"));
	s_log.info("MR4C native library found at [{}]", Mr4cLibrary.JNA_NATIVE_LIB.getFile().getAbsolutePath());
	String libName = getAlgorithmConfig().getArtifact();
	s_log.info("Loading native algorithm library [{}]", libName);
	m_lib = JnaUtils.loadLibrary(libName);
	s_log.info("Native algorithm library found at [{}]", m_lib.getFile().getAbsolutePath());
	for ( String name : getAlgorithmConfig().getExtras() ) {
		s_log.info("Loading extra native library [{}]", name);
		NativeLibrary lib = JnaUtils.loadLibrary(name);
		s_log.info("Extra native library found at [{}]", lib.getFile().getAbsolutePath());
		m_extras.add(lib);
	}
	s_log.info("End loading native libraries");
}
 
開發者ID:google,項目名稱:mr4c,代碼行數:19,代碼來源:JnaNativeAlgorithm.java

示例5: initialize

import com.sun.jna.NativeLibrary; //導入依賴的package包/類
@Override
   public void initialize(IWorkbenchConfigurer configurer) {
super.initialize(configurer);
org.eclipse.ui.ide.IDE.registerAdapters();
declareWorkbenchImages();

boolean found = false;
String vlcLib = ManagementFactory.getRuntimeMXBean().getSystemProperties().get("vlc");
if (vlcLib != null) {
    found = true;
    NativeLibrary.addSearchPath("vlc", vlcLib);
}
if (!found) {
    found = new NativeDiscovery().discover();
}
if (!found) {
    MessageDialog.openError(PlatformUI.getWorkbench().getDisplay().getActiveShell(), "Error", "Cannot play videos.  VLC is either not installed or located in an unexpected directory.  " + "If VLC is installed in an unexpected directory you can provide the path to its library. " + "Find SynergyView.ini and add a line to the end (if not already there) starting with " + "-Dvlc= followed by the path to an installation instance of VLC's lib folder.");
}

   }
 
開發者ID:synergynet,項目名稱:synergyview,代碼行數:21,代碼來源:ApplicationWorkbenchAdvisor.java

示例6: getWin32NativeLibrary

import com.sun.jna.NativeLibrary; //導入依賴的package包/類
private static NativeLibrary getWin32NativeLibrary(String name) {
    //
    // gstreamer on win32 names the dll files one of foo.dll, libfoo.dll and libfoo-0.dll
    //
    String[] nameFormats = { 
        "%s", "lib%s", "lib%s-0",                   
    };
    for (int i = 0; i < nameFormats.length; ++i) {
        try {
            return NativeLibrary.getInstance(String.format(nameFormats[i], name));
        } catch (UnsatisfiedLinkError ex) {                
            continue;
        }
    }
    throw new UnsatisfiedLinkError("Could not load library " + name);
}
 
開發者ID:armouroflight,項目名稱:java-gobject,代碼行數:17,代碼來源:GNative.java

示例7: isAeroEnabled

import com.sun.jna.NativeLibrary; //導入依賴的package包/類
public static boolean isAeroEnabled(){		
    if( HearthHelper.getOSName().equals("win") && DWM == null){
    	try{
    		DWM = NativeLibrary.getInstance("dwmapi");
    	} catch(Throwable e) {}
    }
    
    boolean dwmEnabled = false;
    
       if(DWM != null){
       	boolean[] bool = { false };
       	Object[] args = { bool };
       	Function DwmIsCompositionEnabled = DWM.getFunction("DwmIsCompositionEnabled");
       	HRESULT result = (HRESULT) DwmIsCompositionEnabled.invoke(HRESULT.class, args);
       	boolean success = result.intValue()==0;
       	
       	if(success && bool[0]){
       		dwmEnabled = true;
       	}
       }  

    return dwmEnabled;
}
 
開發者ID:megablue,項目名稱:Hearthtracker,代碼行數:24,代碼來源:HearthRobot.java

示例8: startup

import com.sun.jna.NativeLibrary; //導入依賴的package包/類
@Override
public void startup() throws PluginException {
	
	try {
		LOGGER.info("Initializing Praat library");
		
		final String praatSearchFolder = 
				PrefHelper.get(PRAAT_SEARCH_FOLDER, null);
		if(praatSearchFolder != null) {
			NativeLibrary.addSearchPath("praat", praatSearchFolder);
		}
		
		Praat.INSTANCE.praat_lib_init();
		
		final PraatVersion praatVersion = PraatVersion.getVersion();
		// print version information to log
		final StringBuilder sb = new StringBuilder();
		sb.append("Praat version: ").append(praatVersion.versionStr);
		sb.append(" ").append(praatVersion.day).append('-').append(praatVersion.month).append('-').append(praatVersion.year);
		LOGGER.info(sb.toString());
	} catch (UnsatisfiedLinkError e) {
		LOGGER.log(Level.SEVERE, e.getLocalizedMessage(), e);
	}
}
 
開發者ID:phon-ca,項目名稱:phon-praat-plugin,代碼行數:25,代碼來源:PraatStartupHook.java

示例9: loadVlc

import com.sun.jna.NativeLibrary; //導入依賴的package包/類
public static void loadVlc() {
//        String os = System.getProperty("os.name").toLowerCase();
//        boolean is64bit = "64".equals(System.getProperty("sun.arch.data.model"));
        if (Config.isWindows()) {
            // windows
            if (Config.is64bit()) {
                System.out.println("Loading 64 bit Windows Libraries.");
                NativeLibrary.addSearchPath("libvlc", Config.VLC_URL + "windows" + File.separator + "x64" + File.separator);
            } else {
                System.out.println("Loading 32 bit Windows Libraries.");
                NativeLibrary.addSearchPath("libvlc", Config.VLC_URL + "windows" + File.separator + "x86" + File.separator);
            }
        } else if (Config.isMac()) {
            // mac
        } else if (Config.isLinux()) {
            // linus
        } else if (Config.isSolaris()) {
            // solaris
        }
    }
 
開發者ID:dipacs,項目名稱:Viwib,代碼行數:21,代碼來源:Main.java

示例10: openLib

import com.sun.jna.NativeLibrary; //導入依賴的package包/類
public static WinscardLibInfo openLib() {
	String libraryName = Platform.isWindows() ? WINDOWS_PATH : Platform.isMac() ? MAC_PATH : PCSC_PATH;
	HashMap<String, Object> options = new HashMap<String, Object>();
	if (Platform.isWindows()) {
		options.put(Library.OPTION_FUNCTION_MAPPER, new WindowsFunctionMapper());
	} else if (Platform.isMac()) {
		options.put(Library.OPTION_FUNCTION_MAPPER, new MacFunctionMapper());
	}
	WinscardLibrary lib = (WinscardLibrary) Native.loadLibrary(libraryName, WinscardLibrary.class, options);
	NativeLibrary nativeLibrary = NativeLibrary.getInstance(libraryName);
	// SCARD_PCI_* is #defined to the following symbols (both pcsclite and winscard)
	ScardIoRequest SCARD_PCI_T0 = new ScardIoRequest(nativeLibrary.getGlobalVariableAddress("g_rgSCardT0Pci"));
	ScardIoRequest SCARD_PCI_T1 = new ScardIoRequest(nativeLibrary.getGlobalVariableAddress("g_rgSCardT1Pci"));
	ScardIoRequest SCARD_PCI_RAW = new ScardIoRequest(nativeLibrary.getGlobalVariableAddress("g_rgSCardRawPci"));
	SCARD_PCI_T0.read();
	SCARD_PCI_T1.read();
	SCARD_PCI_RAW.read();
	SCARD_PCI_T0.setAutoSynch(false);
	SCARD_PCI_T1.setAutoSynch(false);
	SCARD_PCI_RAW.setAutoSynch(false);
	return new WinscardLibInfo(lib, SCARD_PCI_T0, SCARD_PCI_T1, SCARD_PCI_RAW);
}
 
開發者ID:jnasmartcardio,項目名稱:jnasmartcardio,代碼行數:23,代碼來源:Winscard.java

示例11: ensureVLCLib

import com.sun.jna.NativeLibrary; //導入依賴的package包/類
/**
 * Ensures that the vlcj Lib is properly loaded
 */
public synchronized static void ensureVLCLib(){

	if(!vlcjLoaded && !vlcjLoadError)
	{
		String vlclibName = RuntimeUtil.getLibVlcLibraryName();
		List<String> libPaths = VLCUtil.getVLCLibPaths();
		logger.info("jni loading: " + vlclibName);


		for (String libPath : libPaths) {
               logger.debug("adding search path: " + libPath);
			NativeLibrary.addSearchPath(vlclibName, libPath);
		}

		try{
			Native.loadLibrary(vlclibName, LibVlc.class);
			vlcjLoaded = true;
		}catch(UnsatisfiedLinkError e){
			vlcjLoadError = true;
			logger.error(e);
		}
	}
}
 
開發者ID:Vidada-Project,項目名稱:vidada-desktop,代碼行數:27,代碼來源:VLCjUtil.java

示例12: initVideoImportEngine

import com.sun.jna.NativeLibrary; //導入依賴的package包/類
@Override
public void initVideoImportEngine(Optional<String> pathToLibrary) {
	if (pathToLibrary.isPresent()) {
		log.debug("Path to library {}", pathToLibrary);
		NativeLibrary.addSearchPath(RuntimeUtil.getLibVlcLibraryName(), pathToLibrary.get());
		Native.loadLibrary(RuntimeUtil.getLibVlcLibraryName(), LibVlc.class);
		log.debug("Library loaded");
	}
}
 
開發者ID:KodeMunkie,項目名稱:imagetozxspec,代碼行數:10,代碼來源:VLCVideoImportEngine.java

示例13: getStdOutNo

import com.sun.jna.NativeLibrary; //導入依賴的package包/類
public int getStdOutNo() {
	try {
		return CLibrary.INSTANCE.fileno(NativeLibrary.getInstance("c")
				.getFunction(getStdOutName()).getPointer(0));
	} catch (Throwable ex) {
		log("error getting stdout no -> return default. " + ex.getMessage());
	}
	return 1;
}
 
開發者ID:yajsw,項目名稱:yajsw,代碼行數:10,代碼來源:PosixProcess.java

示例14: getStdErrNo

import com.sun.jna.NativeLibrary; //導入依賴的package包/類
public int getStdErrNo() {
	try {
		return CLibrary.INSTANCE.fileno(NativeLibrary.getInstance("c")
				.getFunction(getStdErrName()).getPointer(0));
	} catch (Throwable ex) {
		log("error getting stderr no -> return default. " + ex.getMessage());
	}
	return 2;
}
 
開發者ID:yajsw,項目名稱:yajsw,代碼行數:10,代碼來源:PosixProcess.java

示例15: getStdInNo

import com.sun.jna.NativeLibrary; //導入依賴的package包/類
public int getStdInNo() {
	try {
		return CLibrary.INSTANCE.fileno(NativeLibrary.getInstance("c")
				.getFunction(getStdInName()).getPointer(0));
	} catch (Throwable ex) {
		log("error getting stdin no -> return default. " + ex.getMessage());
	}
	return 0;
}
 
開發者ID:yajsw,項目名稱:yajsw,代碼行數:10,代碼來源:PosixProcess.java


注:本文中的com.sun.jna.NativeLibrary類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。