Example usage for org.apache.commons.lang3 SystemUtils IS_OS_WINDOWS

List of usage examples for org.apache.commons.lang3 SystemUtils IS_OS_WINDOWS

Introduction

In this page you can find the example usage for org.apache.commons.lang3 SystemUtils IS_OS_WINDOWS.

Prototype

boolean IS_OS_WINDOWS

To view the source code for org.apache.commons.lang3 SystemUtils IS_OS_WINDOWS.

Click Source Link

Document

Is true if this is Windows.

Usage

From source file:com.mirth.connect.manager.ServiceControllerFactory.java

public static ServiceController getServiceController() throws Exception {
    synchronized (ServiceController.class) {
        if (serviceController == null) {
            if (SystemUtils.IS_OS_WINDOWS) {
                serviceController = new WindowsServiceController();
            } else if (SystemUtils.IS_OS_MAC) {
                serviceController = new MacServiceController();
            } else if (SystemUtils.IS_OS_UNIX) {
                serviceController = new LinuxServiceController();
            } else {
                throw new Exception("Operating system must be Windows, Mac, or Unix/Linux.");
            }/*from ww w  . ja  v a2s . co  m*/
        }

        return serviceController;
    }
}

From source file:com.github.riccardove.easyjasub.commons.CommonsLangSystemUtils.java

public static boolean isWindows() {
    return SystemUtils.IS_OS_WINDOWS;
}

From source file:com.ts.utils.win.RegistryUtils.java

public static String getStringValue(HKEY inHive, int inWow64or32value, String inKeyName,
        String inPropertyName) {//w  w w. j  a  v a2s  . co  m
    String retValue;
    if (!SystemUtils.IS_OS_WINDOWS) {
        throw new java.lang.UnsupportedOperationException("This method is only for Windows OS.");
    }
    HKEYByReference phkKey = new HKEYByReference();
    int rc = Advapi32.INSTANCE.RegOpenKeyEx(inHive, inKeyName, 0, WinNT.KEY_QUERY_VALUE | inWow64or32value,
            phkKey);
    if (rc != W32Errors.ERROR_SUCCESS) {
        throw new Win32Exception(rc);
    }
    try {
        retValue = Advapi32Util.registryGetStringValue(phkKey.getValue(), inPropertyName);
    } finally {
        rc = Advapi32.INSTANCE.RegCloseKey(phkKey.getValue());
        if (rc != W32Errors.ERROR_SUCCESS) {
            throw new Win32Exception(rc);
        }
    }
    return retValue;
}

From source file:gr.aueb.dmst.istlab.unixtools.util.EclipsePluginUtil.java

public static List<String> getSystemShellInfo() {
    List<String> shellInfo = new ArrayList<>();

    if (SystemUtils.IS_OS_LINUX) {
        shellInfo.add("/bin/bash");
        shellInfo.add("-c");
    } else if (SystemUtils.IS_OS_FREE_BSD) {
        shellInfo.add("");
        shellInfo.add("");
    } else if (SystemUtils.IS_OS_WINDOWS) {
        String value = Activator.getDefault().getPreferenceStore().getString(PropertiesLoader.SHELL_PATH_KEY);
        String cygwin = path(value) ? value + "bash.exe" : value + "/bash.exe";
        shellInfo.add("CMD");
        shellInfo.add("/C");
        shellInfo.add(cygwin.replace("\\", "/") + " --login -c ");
    } else if (SystemUtils.IS_OS_MAC_OSX) {
        shellInfo.add("/bin/sh");
        shellInfo.add("-c");
    }//from  ww w.  j av  a  2s . co m

    return shellInfo;
}

From source file:com.officialgenius.brainiac.Brainiac.java

/**
 * Get Dropbox path of the system//from  w  w  w .  j  ava 2  s. c  om
 * @return path of dropbox folder
 * @throws IOException
 */

public static String getDropBoxPath() throws IOException {
    Diodable diode = null;
    if (SystemUtils.IS_OS_WINDOWS) {
        diode = new WindowsDiode();
    } else if (SystemUtils.IS_OS_LINUX || SystemUtils.IS_OS_MAC) {
        diode = new NixDiode();
    }
    return diode != null ? diode.getDropBoxPath() : null;
}

From source file:com.synopsys.integration.util.OperatingSystemType.java

public static OperatingSystemType determineFromSystem() {
    if (SystemUtils.IS_OS_MAC) {
        return MAC;
    } else if (SystemUtils.IS_OS_WINDOWS) {
        return WINDOWS;
    } else {/*from  w w  w  .j av a2 s  .co m*/
        return LINUX;
    }
}

From source file:io.vertx.config.vault.utils.VaultDownloader.java

public static File download() {
    File out = new File("target/vault/vault");

    if (SystemUtils.IS_OS_WINDOWS) {
        out = new File("target/vault/vault.exe");
    }/* w  w w. j av a  2 s.c  o  m*/

    if (out.isFile()) {
        return out;
    }

    File zip = new File("target/vault.zip");

    try {
        FileUtils.copyURLToFile(getURL(VaultProcess.VAULT_VERSION), zip);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    assert zip.isFile();

    System.out.println(zip.getAbsolutePath() + " has been downloaded, unzipping");
    try {
        unzip(zip, out.getParentFile());
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    System.out.println("Vault: " + out.getAbsolutePath());
    assert out.isFile();
    out.setExecutable(true);
    assert out.canExecute();
    return out;
}

From source file:io.ucoin.ucoinj.elasticsearch.util.Desktop.java

public static DesktopPower getDesktopPower() {
    if (desktopPower == null) {

        if (SystemUtils.IS_OS_WINDOWS) {
            // All Windows version are handled with WindowsPower class
            try {
                desktopPower = new WindowsPower();
            } catch (Exception e) {
                LOG.error(e.getLocalizedMessage(), e);
            }//from   www .j ava 2  s. com

        } else if (SystemUtils.IS_OS_LINUX) {

            // TODO create a Linux/UnixPower because (for example) Kubuntu sends KILL signal when it shutdown, it should sent TERM !!
        }

    }

    return desktopPower;
}

From source file:com.qwazr.utils.process.ProcessUtils.java

public static Integer kill(Number pid) throws IOException, InterruptedException {
    if (pid == null)
        return null;
    final String commandLine;
    if (SystemUtils.IS_OS_UNIX)
        commandLine = "kill  " + pid;
    else if (SystemUtils.IS_OS_WINDOWS)
        commandLine = "taskkill /PID " + pid;
    else/*from  w w w  .  ja  va  2  s . co m*/
        throw new IOException(NOT_SUPPORTED_ERROR);
    return run(commandLine);
}

From source file:net.chris54721.infinitycubed.utils.Utils.java

public static File getAppdataPath() {
    if (SystemUtils.IS_OS_WINDOWS)
        return new File(System.getenv("APPDATA"));
    if (SystemUtils.IS_OS_MAC_OSX)
        return new File(System.getProperty("user.home") + "/Library/Application Support");
    if (SystemUtils.IS_OS_LINUX)
        return new File(System.getProperty("user.home"));
    return new File(System.getProperty("user.home"));
}