List of usage examples for org.apache.commons.lang SystemUtils IS_OS_WINDOWS
boolean IS_OS_WINDOWS
To view the source code for org.apache.commons.lang SystemUtils IS_OS_WINDOWS.
Click Source Link
Is true
if this is Windows.
The field will return false
if OS_NAME
is null
.
From source file:VASSAL.tools.io.TempFileManager.java
private TempFileManager() { ////from w w w. j a va 2 s . c o m // set up for cleanup on shutdown // if (SystemUtils.IS_OS_WINDOWS) { Runtime.getRuntime().addShutdownHook(new Thread() { public void run() { // Run the garbage collector and finalize repeatedly, with // exponentially increasing pauses, until we succeed at deleting // the whole session temp directory or we hit the sleep limit. long sleep = 1; final long maxsleep = 1024; while (true) { System.gc(); System.runFinalization(); try { cleanupSessionRoot(); break; } catch (IOException e) { if (sleep > maxsleep) { // just log, since shutdown hooks don't have long to run logger.error("", e); break; } try { Thread.sleep(sleep); } catch (InterruptedException ignore) { } sleep *= 2; } } } }); } else { Runtime.getRuntime().addShutdownHook(new Thread() { public void run() { try { cleanupSessionRoot(); } catch (IOException e) { // just log, since shutdown hooks don't have long to run logger.error("", e); } } }); } tmpRoot = Info.getTempDir(); // // clean up stale temporary files // if (tmpRoot.exists() && tmpRoot.isDirectory()) { final FileFilter filter = new FileFilter() { public boolean accept(File f) { return f.isDirectory() && f.getName().startsWith(DIR_PREFIX); } }; for (File f : tmpRoot.listFiles(filter)) { final File lock = new File(f.getParent(), f.getName() + ".lck"); if (!lock.exists()) { try { FileUtils.forceDelete(f); } catch (IOException e) { logger.error("", e); } } } } }
From source file:VASSAL.tools.lang.MemoryUtils.java
/** * Gets the amount of physical memory (RAM) in this machine, in bytes. * * @return the amount of RAM, in bytes; or -1 if the amount of RAM * cannot be queried./*from w w w. j av a2s . c om*/ */ public static long getPhysicalMemory() { if (!SystemUtils.IS_OS_WINDOWS || SystemUtils.IS_OS_WINDOWS_98 || SystemUtils.IS_OS_WINDOWS_ME) { // Windows 98, ME support a maximum of 2GB RAM, so are unaffected // by the bug which causes incorrect reporting over 2GB. Hence, // we can handle them in the normal way. final Object o = ManagementFactory.getOperatingSystemMXBean(); try { if (o instanceof OperatingSystemMXBean) { final OperatingSystemMXBean osb = (OperatingSystemMXBean) o; return osb.getTotalPhysicalMemorySize(); } } catch (NoClassDefFoundError e) { // com.sun.management.OperatingSystemMXBean doesn't exist in this JVM } // We didn't get a com.sun.management.OperatingSystemMXBean. return -1; } else { // FIXME: totalPhysicalMemorySize() doesn't return the correct result // on Windows machines with more than 2GB RAM, so we have to call // GlobalMemoryStatusEx ourselves instead of letting the bean do it // for us. See Sun Bug 6853676. This case can be removed when the bug // is fixed in a released JVM. // The Windows Kernel32 call GlobalMemoryStatusEx() fills a // MEMORYSTATUSEX structure with various facts about memory usage. final Kernel32.MEMORYSTATUSEX mstat = new Kernel32.MEMORYSTATUSEX(); if (Kernel32.INSTANCE.GlobalMemoryStatusEx(mstat)) { return mstat.ullTotalPhys; } else { // GlobalMemoryStatusEx failed final PointerByReference lpBuffer = new PointerByReference(); final int errno = Native.getLastError(); final int msglen = Kernel32.INSTANCE.FormatMessage( Kernel32.FORMAT_MESSAGE_ALLOCATE_BUFFER | Kernel32.FORMAT_MESSAGE_FROM_SYSTEM, Pointer.NULL, errno, 0, lpBuffer, 0, Pointer.NULL); final String message = msglen > 0 ? lpBuffer.getValue().getStringArray(0)[0] : "no message"; throw new RuntimeException("Error " + errno + ": " + message); } } }
From source file:VASSAL.tools.lang.MemoryUtilsTest.java
@Ignore @Test public void testGetPhysicalMemoryWindows() { assumeTrue(SystemUtils.IS_OS_WINDOWS); }
From source file:zhuravlik.maven.vix.LibraryHelper.java
public static void setLibraryPath(String path) { if (path != null) System.setProperty("jna.library.path", path); else if (SystemUtils.IS_OS_WINDOWS) { File dir = new File("C:/Program Files/VMware/VMware VIX/"); String[] list = dir.list(); for (String fl : list) { if (fl.contains("Workstation-") || fl.contains("Server-") || fl.contains("Player-")) { //logger.info("Detected " + fl); File wdir = new File("C:/Program Files/VMware/VMware VIX/" + fl); String[] wlist = wdir.list(); for (String pfl : wlist) { if (pfl.equals("64bit") || pfl.equals("32bit")) { System.setProperty("jna.library.path", "C:/Program Files/VMware/VMware VIX/" + fl + "/" + pfl); //log("JNA library path is set to: " + "C:/Program Files/VMware/VMware VIX/" + fl + "/" + pfl, Project.MSG_INFO); }//w ww .j ava 2 s. co m } } } } else { System.setProperty("jna.library.path", "/usr/lib/vmware-vix/"); //log("JNA library path is set to: /usr/lib/vmware-vix/", Project.MSG_INFO); } }