Example usage for org.apache.commons.lang SystemUtils IS_OS_WINDOWS_98

List of usage examples for org.apache.commons.lang SystemUtils IS_OS_WINDOWS_98

Introduction

In this page you can find the example usage for org.apache.commons.lang SystemUtils IS_OS_WINDOWS_98.

Prototype

boolean IS_OS_WINDOWS_98

To view the source code for org.apache.commons.lang SystemUtils IS_OS_WINDOWS_98.

Click Source Link

Document

Is true if this is Windows 98.

The field will return false if OS_NAME is null.

Usage

From source file:org.n0pe.asadmin.AsAdmin.java

/**
 * Run the given AsAdmin command./*w w  w .j  av a2 s.co m*/
 * 
 * @param cmd AsAdmin command to be run
 * @throws org.n0pe.asadmin.AsAdminException AsAdminException
 */
public void run(final IAsAdminCmd cmd) throws AsAdminException {
    try {
        final File gfBinPath = new File(config.getGlassfishHome() + File.separator + "bin");
        final String[] cmds = buildProcessParams(cmd, config);
        cmds[0] = gfBinPath + File.separator + cmds[0];
        int exitCode;
        final Process proc;
        String[] env = buildEnvironmentStrings(config.getEnvironmentVariables());
        if (SystemUtils.IS_OS_WINDOWS) {
            // Windows
            final String command = "\"\"" + StringUtils.join(cmds, "\" \"") + "\"\"";
            final String[] windowsCommand;
            if (SystemUtils.IS_OS_WINDOWS_95 || SystemUtils.IS_OS_WINDOWS_98 || SystemUtils.IS_OS_WINDOWS_ME) {
                windowsCommand = new String[] { "command.com", "/C", command };
            } else {
                windowsCommand = new String[] { "cmd.exe", "/C", command };
            }
            outPrintln("Will run the following command: " + StringUtils.join(windowsCommand, " "));
            if (env.length > 0) {
                proc = Runtime.getRuntime().exec(windowsCommand, env);
            } else {
                proc = Runtime.getRuntime().exec(windowsCommand);
            }
        } else {
            // Non Windows
            outPrintln("Will run the following command: " + StringUtils.join(cmds, " "));
            proc = Runtime.getRuntime().exec(cmds, env);
        }
        final ProcessStreamGobbler errorGobbler = new ProcessStreamGobbler(cmd, proc.getErrorStream(),
                ProcessStreamGobbler.ERROR);
        final ProcessStreamGobbler outputGobbler = new ProcessStreamGobbler(cmd, proc.getInputStream(),
                ProcessStreamGobbler.OUTPUT);
        errorGobbler.start();
        outputGobbler.start();
        exitCode = proc.waitFor();
        if (exitCode != 0) {
            throw new AsAdminException("asadmin invocation failed and returned : " + String.valueOf(exitCode));
        }
    } catch (final InterruptedException ex) {
        throw new AsAdminException("AsAdmin error occurred: " + ex.getMessage(), ex);
    } catch (final IOException ex) {
        throw new AsAdminException("AsAdmin error occurred: " + ex.getMessage(), ex);
    }
}

From source file:org.openmicroscopy.shoola.util.ui.UIUtilities.java

/**
 * Returns <code>true</code> if the OS is Windows, <code>false</code>
 * otherwise.//ww w.  j  a va  2  s. co m
 * 
 * @return See above.
 */
public static boolean isWindowsOS() {
    //String osName = System.getProperty("os.name").toLowerCase();
    //return osName.startsWith("windows");
    return (SystemUtils.IS_OS_WINDOWS || SystemUtils.IS_OS_WINDOWS_2000 || SystemUtils.IS_OS_WINDOWS_7
            || SystemUtils.IS_OS_WINDOWS_95 || SystemUtils.IS_OS_WINDOWS_98 || SystemUtils.IS_OS_WINDOWS_ME
            || SystemUtils.IS_OS_WINDOWS_NT || SystemUtils.IS_OS_WINDOWS_VISTA || SystemUtils.IS_OS_WINDOWS_XP);
}

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./*  w w  w  .j a v  a 2s  .  com*/
 */
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);
        }
    }
}