当前位置: 首页>>代码示例>>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;未经允许,请勿转载。