当前位置: 首页>>代码示例>>Java>>正文


Java Platform.isWindows方法代码示例

本文整理汇总了Java中com.sun.jna.Platform.isWindows方法的典型用法代码示例。如果您正苦于以下问题:Java Platform.isWindows方法的具体用法?Java Platform.isWindows怎么用?Java Platform.isWindows使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.sun.jna.Platform的用法示例。


在下文中一共展示了Platform.isWindows方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: dndWithCopy

import com.sun.jna.Platform; //导入方法依赖的package包/类
public void dndWithCopy() throws Throwable {
    DesiredCapabilities caps = new DesiredCapabilities();
    // caps.setCapability("nativeEvents", true);
    driver = new JavaDriver(caps, caps);
    WebElement list = driver.findElement(By.cssSelector("list"));
    assertEquals(
            "[[\"List Item 0\",\"List Item 1\",\"List Item 2\",\"List Item 3\",\"List Item 4\",\"List Item 5\",\"List Item 6\",\"List Item 7\",\"List Item 8\",\"List Item 9\"]]",
            list.getAttribute("content"));
    WebElement listitem1 = driver.findElement(By.cssSelector("list::nth-item(1)"));
    WebElement listitem5 = driver.findElement(By.cssSelector("list::nth-item(5)"));
    listitem1.click();
    driver.clearlogs(LogType.DRIVER);
    Keys copyKey = Keys.ALT;
    if (Platform.isWindows()) {
        copyKey = Keys.CONTROL;
    }
    new Actions(driver).keyDown(copyKey).dragAndDrop(listitem1, listitem5).keyUp(copyKey).perform();
    waitTillDropCompletes(
            "[[\"List Item 0\",\"List Item 1\",\"List Item 2\",\"List Item 3\",\"List Item 0(1)\",\"List Item 5\",\"List Item 6\",\"List Item 7\",\"List Item 8\",\"List Item 9\"]]",
            list);
    assertEquals(
            "[[\"List Item 0\",\"List Item 1\",\"List Item 2\",\"List Item 3\",\"List Item 0(1)\",\"List Item 5\",\"List Item 6\",\"List Item 7\",\"List Item 8\",\"List Item 9\"]]",
            list.getAttribute("content"));
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:25,代码来源:DragAndDropTest.java

示例2: findExecutableOnPath

import com.sun.jna.Platform; //导入方法依赖的package包/类
public static String findExecutableOnPath(String name) {
    if (!Platform.isWindows() || name.endsWith(".exe") || name.endsWith(".bat")) {
        return getPathTo(name);
    }
    String path;
    path = getPathTo(name + ".exe");
    if (path != null)
        return path;
    path = getPathTo(name + ".cmd");
    if (path != null)
        return path;
    return getPathTo(name + ".bat");
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:14,代码来源:LaunchWebStartTest.java

示例3: getHostname

import com.sun.jna.Platform; //导入方法依赖的package包/类
/**
 * @return the hostname the of the current machine
 */
public static String getHostname() {
    if (Platform.isWindows()) {
        return Kernel32Util.getComputerName();
    } else {
        // For now, we'll consider anyhting other than Windows to be unix-ish enough to have gethostname
        // TODO - Consider http://stackoverflow.com/a/10543006 as a possibly better MacOS option
        
        byte[] hostnameBuffer = new byte[4097];
        // http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/limits.h.html suggests
        // the actual limit would be 255.
        
        int result = UnixCLibrary.INSTANCE.gethostname(hostnameBuffer, hostnameBuffer.length);
        if (result != 0) {
            throw new RuntimeException("gethostname call failed");
        }
        
        return Native.toString(hostnameBuffer);
    }
}
 
开发者ID:mattsheppard,项目名称:gethostname4j,代码行数:23,代码来源:Hostname.java

示例4: getImplInstance

import com.sun.jna.Platform; //导入方法依赖的package包/类
private static final NativeCalls getImplInstance() {
  if (Platform.isLinux()) {
    return new LinuxNativeCalls();
  }
  if (Platform.isWindows()) {
    return new WinNativeCalls();
  }
  if (Platform.isSolaris()) {
    return new SolarisNativeCalls();
  }
  if (Platform.isMac()) {
    return new MacOSXNativeCalls();
  }
  if (Platform.isFreeBSD()) {
    return new FreeBSDNativeCalls();
  }
  return new POSIXNativeCalls();
}
 
开发者ID:ampool,项目名称:monarch,代码行数:19,代码来源:NativeCallsJNAImpl.java

示例5: getProcessId

import com.sun.jna.Platform; //导入方法依赖的package包/类
/**
 * Retrieves the process ID (PID) for the specified {@link Process}.
 *
 * @param process the {@link Process} for whose PID to retrieve.
 * @return The PID or zero if the PID couldn't be retrieved.
 */
public static int getProcessId(@Nullable Process process) {
	if (process == null) {
		return 0;
	}
	try {
		Field field;
		if (Platform.isWindows()) {
			field = process.getClass().getDeclaredField("handle");
			field.setAccessible(true);
			int pid = Kernel32.INSTANCE.GetProcessId(new HANDLE(new Pointer(field.getLong(process))));
			if (pid == 0 && LOGGER.isDebugEnabled()) {
				int lastError = Kernel32.INSTANCE.GetLastError();
				LOGGER.debug("KERNEL32.getProcessId() failed with error {}", lastError);
			}
			return pid;
		}
		field = process.getClass().getDeclaredField("pid");
		field.setAccessible(true);
		return field.getInt(process);
	} catch (Exception e) {
		LOGGER.warn("Failed to get process id for process \"{}\": {}", process, e.getMessage());
		LOGGER.trace("", e);
		return 0;
	}
}
 
开发者ID:DigitalMediaServer,项目名称:DigitalMediaServer,代码行数:32,代码来源:ProcessManager.java

示例6: installSslLib

import com.sun.jna.Platform; //导入方法依赖的package包/类
/**
 * 安装ssllib到c:\windown\system32下
 */
static void installSslLib(ClassLoader classLoader, String ospath, String name) {
	String libname = mapSharedLibraryName(name);//lib全名.dll .so
	if(Platform.isWindows()) {
		String fullPath = "C:\\Windows\\System32\\" + libname;
		File dest = new File(fullPath);
		if(!dest.exists()) {
			File dir = dest.getParentFile();
	    	if(!dir.exists()) {
	    		dir.mkdirs();
	    	}
        	String libClassPath = ospath + "/" + libname;
			extract(classLoader, libClassPath, dest);
		} else {
			System.out.println("have install : " + fullPath);
		}
	}
}
 
开发者ID:xtuhcy,项目名称:webkit4j,代码行数:21,代码来源:InstallLibs.java

示例7: byName

import com.sun.jna.Platform; //导入方法依赖的package包/类
public static Process byName(String name) {
	if (Platform.isWindows()) {
		Tlhelp32.PROCESSENTRY32.ByReference entry = new Tlhelp32.PROCESSENTRY32.ByReference();
		Pointer snapshot = Kernel32.CreateToolhelp32Snapshot(Tlhelp32.TH32CS_SNAPALL.intValue(), 0);
		try {
			while (Kernel32.Process32Next(snapshot, entry)) {
				String processName = Native.toString(entry.szExeFile);
				if (name.equals(processName)) {
					return byId(entry.th32ProcessID.intValue());
				}
			}
		} finally {
			Kernel32.CloseHandle(snapshot);
		}
	} else if (Platform.isMac() || Platform.isLinux()) {
		return byId(Utils.exec("bash", "-c", "ps -A | grep -m1 \"" + name + "\" | awk '{print $1}'"));
	} else {
		throw new UnsupportedOperationException("Unknown operating system! (" + System.getProperty("os.name") + ")");
	}
	throw new IllegalStateException("Process '" + name + "' was not found. Are you sure its running?");
}
 
开发者ID:Jonatino,项目名称:Java-Memory-Manipulation,代码行数:22,代码来源:Processes.java

示例8: runInSameThread

import com.sun.jna.Platform; //导入方法依赖的package包/类
@Override
public void runInSameThread() {
	if (!Platform.isWindows()) {
		mkin.getPipeProcess().runInNewThread();
		mkout.getPipeProcess().runInNewThread();

		// Allow the threads some time to do their work before
		// running the main thread
		try {
			Thread.sleep(150);
		} catch (InterruptedException e) {
		}
	}

	run();
}
 
开发者ID:DigitalMediaServer,项目名称:DigitalMediaServer,代码行数:17,代码来源:PipeIPCProcess.java

示例9: registerPlayers

import com.sun.jna.Platform; //导入方法依赖的package包/类
/**
 * Registers known transcoding engines.
 *
 * @throws InterruptedException
 */
private static void registerPlayers() throws InterruptedException {
	if (Platform.isWindows()) {
		registerPlayer(new AviSynthFFmpeg());
		registerPlayer(new AviSynthMEncoder());
	}

	registerPlayer(new FFmpegAudio());
	registerPlayer(new MEncoderVideo());
	registerPlayer(new FFMpegVideo());
	registerPlayer(new VLCVideo());
	registerPlayer(new FFmpegWebVideo());
	registerPlayer(new MEncoderWebVideo());
	registerPlayer(new VLCWebVideo());
	registerPlayer(new TsMuxeRVideo());
	registerPlayer(new TsMuxeRAudio());
	registerPlayer(new VideoLanAudioStreaming());
	registerPlayer(new VideoLanVideoStreaming());
	registerPlayer(new DCRaw());
}
 
开发者ID:DigitalMediaServer,项目名称:DigitalMediaServer,代码行数:25,代码来源:PlayerFactory.java

示例10: runInNewThread

import com.sun.jna.Platform; //导入方法依赖的package包/类
@Override
public void runInNewThread() {
	if (!Platform.isWindows()) {
		mkin.getPipeProcess().runInNewThread();
		mkout.getPipeProcess().runInNewThread();

		// Allow the threads some time to do their work before
		// starting the main thread
		try {
			Thread.sleep(150);
		} catch (InterruptedException e) {
		}
	}

	start();
}
 
开发者ID:DigitalMediaServer,项目名称:DigitalMediaServer,代码行数:17,代码来源:PipeIPCProcess.java

示例11: filterPlugins

import com.sun.jna.Platform; //导入方法依赖的package包/类
@Test
public void filterPlugins() {
    if (Platform.isWindows()) {
        return; // gst_registry_plugin_filter doesn't exist on windows
    }
    final String PLUGIN = "vorbis"; // Use something that is likely to be there
    Registry registry = Registry.getDefault();
    // Ensure some plugins are loaded
    ElementFactory.make("playbin", "test");
    ElementFactory.make("vorbisdec", "vorbis");
    ElementFactory.make("decodebin", "decoder");
    final boolean[] filterCalled = { false };
    List<Plugin> plugins = registry.getPluginList(new Registry.PluginFilter() {

        public boolean accept(Plugin plugin) {
            filterCalled[0] = true;
            return plugin.getName().equals(PLUGIN);
        }
    }, true);
    assertFalse("No plugins found", plugins.isEmpty());
    assertTrue("PluginFilter not called", filterCalled[0]);
    assertEquals("Plugin list should contain 1 item", 1, plugins.size());
    assertEquals(PLUGIN + " plugin not found", PLUGIN, plugins.get(0).getName());
}
 
开发者ID:gstreamer-java,项目名称:gstreamer1.x-java,代码行数:25,代码来源:RegistryTest.java

示例12: findCoreLibrary

import com.sun.jna.Platform; //导入方法依赖的package包/类
private static String findCoreLibrary() {
    String path="";
    if (Platform.isWindows()) {
    	try {
	    	path = getCPath(true);
	       	path = Advapi32Util.registryGetStringValue(WinReg.HKEY_LOCAL_MACHINE, path, "InstallDir");
    	} catch (Exception ignored) {
    		try {
		    	path = getCPath(false);
		       	path = Advapi32Util.registryGetStringValue(WinReg.HKEY_LOCAL_MACHINE, path, "InstallDir");
    		} catch (Exception ignored1) {
    			return "";
    		}
    	}
       	path = path + "CoreFoundation.dll";
       	File f = new File(path);
       	if (f.exists())
       		return path;
    } else if (Platform.isMac()) {
         return "/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation";
    }
    return "";
}
 
开发者ID:apicloudcom,项目名称:APICloud-Studio,代码行数:24,代码来源:LibraryFinder.java

示例13: localSocket

import com.sun.jna.Platform; //导入方法依赖的package包/类
@Test
public void localSocket() throws Exception {
    requireMinimumVersion(5, 1);
    Assume.assumeTrue(System.getenv("TRAVIS") == null);
    Assume.assumeTrue(isLocalConnection("localSocket"));

    Statement st = sharedConnection.createStatement();
    ResultSet rs = st.executeQuery("select @@version_compile_os,@@socket");
    if (!rs.next()) {
        return;
    }
    System.out.println("os:" + rs.getString(1) + " path:" + rs.getString(2));
    String os = rs.getString(1);
    if (os.toLowerCase().startsWith("win") || Platform.isWindows()) {
        return;
    }

    String path = rs.getString(2);
    try (Connection connection = setConnection("&localSocket=" + path + "&profileSql=true")) {
        rs = connection.createStatement().executeQuery("select 1");
        assertTrue(rs.next());
    }
}
 
开发者ID:MariaDB,项目名称:mariadb-connector-j,代码行数:24,代码来源:DriverTest.java

示例14: poll

import com.sun.jna.Platform; //导入方法依赖的package包/类
static int poll(final Pollfd pfd, final int nfds, final int timeout) {
    int ready;
    if (Platform.isWindows()) {
        final WsaPollfd wpfd = new WsaPollfd();
        wpfd.fd = pfd.fd;
        wpfd.events = (short) (pfd.events & ~POLLPRI); // WSAPoll() doesn't support 'POLLPRI' according to the MSDN
        wpfd.revents = pfd.revents;

        ready = LIBWS2.WSAPoll(wpfd, nfds, timeout);
        LOG.debug(String.format("WSAPoll(%s, %d, %d); result=%d", wpfd, nfds, timeout, ready));

        pfd.revents = wpfd.revents;
    }
    else {
        ready = LIBC.poll(pfd, nfds, timeout);
        LOG.debug(String.format("poll(%s, %d, %d); result=%d", pfd, nfds, timeout, ready));
    }

    return ready;
}
 
开发者ID:raqet,项目名称:acquisition-server,代码行数:21,代码来源:SocketUtils.java

示例15: dump

import com.sun.jna.Platform; //导入方法依赖的package包/类
public void dump() throws Exception {
    NativeDatagramSocket m_pingSocket =  NativeDatagramSocket.create(NativeDatagramSocket.PF_INET6, Platform.isMac() ? NativeDatagramSocket.SOCK_DGRAM : NativeDatagramSocket.SOCK_RAW, NativeDatagramSocket.IPPROTO_ICMPV6);
    
    if (Platform.isWindows()) {
        ICMPv6EchoPacket packet = new ICMPv6EchoPacket(64);
        packet.setCode(0);
        packet.setType(Type.EchoRequest);
        packet.getContentBuffer().putLong(System.nanoTime());
        packet.getContentBuffer().putLong(System.nanoTime());
        m_pingSocket.send(packet.toDatagramPacket(InetAddress.getByName("::1")));
    }

    try {
        NativeDatagramPacket datagram = new NativeDatagramPacket(65535);
        while (true) {
            m_pingSocket.receive(datagram);
            System.err.println(datagram);
        }


    } catch(Throwable e) {
        e.printStackTrace();
    }
 
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:26,代码来源:Dumper.java


注:本文中的com.sun.jna.Platform.isWindows方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。