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

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

Introduction

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

Prototype

boolean IS_OS_MAC

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

Click Source Link

Document

Is true if this is Mac.

The field will return false if OS_NAME is null.

Usage

From source file:ddf.content.plugin.video.VideoThumbnailPlugin.java

private String getBundledFFmpegBinaryPath() {
    if (SystemUtils.IS_OS_LINUX) {
        return "linux/ffmpeg";
    } else if (SystemUtils.IS_OS_MAC) {
        return "osx/ffmpeg";
    } else if (SystemUtils.IS_OS_SOLARIS) {
        return "solaris/ffmpeg";
    } else if (SystemUtils.IS_OS_WINDOWS) {
        return "windows/ffmpeg.exe";
    } else {//from  w  w  w .  j av a2 s .c  o  m
        throw new RuntimeException("OS is not Linux, Mac, Solaris, or Windows."
                + " No FFmpeg binary is available for this OS, so the plugin will not work.");
    }
}

From source file:com.jayway.maven.plugins.android.AndroidNdk.java

private File findStripper(String toolchain) {
    List<String> osDirectories = new ArrayList<String>();
    String extension = "";

    if (SystemUtils.IS_OS_LINUX) {
        osDirectories.add("linux-x86");
        osDirectories.add("linux-x86_64");
    } else if (SystemUtils.IS_OS_WINDOWS) {
        osDirectories.add("windows");
        osDirectories.add("windows-x86_64");
        extension = ".exe";
    } else if (SystemUtils.IS_OS_MAC || SystemUtils.IS_OS_MAC_OSX) {
        osDirectories.add("darwin-x86");
        osDirectories.add("darwin-x86_64");
    }//from  www. j av a2 s.c o  m

    String fileName = "";
    if (toolchain.startsWith("arm")) {
        fileName = "arm-linux-androideabi-strip" + extension;
    } else if (toolchain.startsWith("x86")) {
        fileName = "i686-linux-android-strip" + extension;
    } else if (toolchain.startsWith("mips")) {
        fileName = "mipsel-linux-android-strip" + extension;
    }

    for (String osDirectory : osDirectories) {
        String stripperLocation = String.format("toolchains/%s/prebuilt/%s/bin/%s", toolchain, osDirectory,
                fileName);
        final File stripper = new File(ndkPath, stripperLocation);
        if (stripper.exists()) {
            return stripper;
        }
    }
    return null;
}

From source file:com.jstar.eclipse.services.Utils.java

public File getJRELibLocation() {
    final StringBuilder location = new StringBuilder(System.getProperty("java.home"));
    location.append(File.separator);

    if (SystemUtils.IS_OS_MAC) {
        location.append("..").append(File.separator).append("Classes").append(File.separator);
    } else {//  w  w  w.j a v  a 2  s . c  o m
        location.append("lib").append(File.separator);
    }

    File locationFile = new File(location.toString());

    if (locationFile.isDirectory()) {
        return locationFile;
    }

    return null;
}

From source file:net.landora.video.utils.UIUtils.java

public static void openBrowser(String url) {
    try {//from  w w w  . j  a  v a  2  s  .  c  o  m
        Desktop.getDesktop().browse(new URI(url));
        return;
    } catch (Exception ignore) {
    }

    List<String> cmd = new ArrayList<String>();

    if (SystemUtils.IS_OS_MAC) {
        cmd.add("open");
    } else if (SystemUtils.IS_OS_WINDOWS) {
        cmd.add("cmd");
        cmd.add("/c");
        cmd.add("start");
    } else {
        cmd.add("xdg-open");
    }

    cmd.add(url);
    try {
        Runtime.getRuntime().exec(cmd.toArray(new String[cmd.size()]));
    } catch (IOException ex) {
        LoggerFactory.getLogger(UIUtils.class).error("Error opening browsner: " + url, ex);
    }
}

From source file:com.casewaresa.framework.util.LegacyJasperInputStream.java

public static InputStream convertStringToInputStream(final String template) {
    InputStream is = null;// ww  w.  j av  a 2  s  .  com
    try {

        if (SystemUtils.IS_OS_WINDOWS) {
            log.trace("### Cargando el objeto desde un ambiente WINDOWS");
            is = new ByteArrayInputStream(template.getBytes("UTF-8"));
        } else if (SystemUtils.IS_OS_LINUX) {
            log.trace("### Cargando el objeto desde un ambiente UNIX (LINUX)");
            is = new ByteArrayInputStream(template.getBytes());
        } else if (SystemUtils.IS_OS_MAC) {
            log.trace("### Cargando el objeto desde un ambiente MAC");
            is = new ByteArrayInputStream(template.getBytes("UTF-8"));
        }

    } catch (UnsupportedEncodingException ex) {
        log.debug(ex.getMessage(), ex);
    }
    return is;
}

From source file:com.jstar.eclipse.services.JStar.java

public void checkConfigurations() throws ConfigurationException {
    if (StringUtils.isEmpty(PreferenceConstants.getJStarExecutable())) {
        throw new ConfigurationException(getErrorMessage("jStar executable"));
    }//from ww  w.j av  a2  s.c o m

    if (StringUtils.isEmpty(PreferenceConstants.getJStarLogicLibrary())) {
        throw new ConfigurationException(getErrorMessage("jStar logic library"));
    }

    if (StringUtils.isEmpty(PreferenceConstants.getJStarSpecLibrary())) {
        throw new ConfigurationException(getErrorMessage("jStar specification library"));
    }

    if (SystemUtils.IS_OS_MAC) {
        if (StringUtils.isEmpty(PreferenceConstants.getSootClassPathClasses())) {
            throw new ConfigurationException(getErrorMessage("classes.jar file in JAVA jre"));
        }

        if (StringUtils.isEmpty(PreferenceConstants.getSootClassPathUi())) {
            throw new ConfigurationException(getErrorMessage("ui.jar file in JAVA jre"));
        }
    } else {
        if (StringUtils.isEmpty(PreferenceConstants.getSootClassPathRt())) {
            throw new ConfigurationException(getErrorMessage("rt.jar file in JAVA jre"));
        }
    }
}

From source file:net.erdfelt.android.sdkfido.ui.SdkFidoFrame.java

private void enableExitKey() {
    InputMap rootInput = getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    ActionMap rootAction = getRootPane().getActionMap();

    if (SystemUtils.IS_OS_UNIX || SystemUtils.IS_OS_WINDOWS) {
        rootInput.put(KeyStroke.getKeyStroke(KeyEvent.VK_F4, InputEvent.CTRL_DOWN_MASK), "exit");
        rootInput.put(KeyStroke.getKeyStroke(KeyEvent.VK_Q, InputEvent.CTRL_DOWN_MASK), "exit");
    }/*from  w  w  w  . j  a va2  s. c om*/

    if (SystemUtils.IS_OS_MAC) {
        rootInput.put(KeyStroke.getKeyStroke(KeyEvent.VK_Q, InputEvent.META_DOWN_MASK), "exit");
    }

    rootAction.put("exit", new KeyAction(actionMapper, "exit"));
}

From source file:com.kurento.test.selenium.BaseSeleniumTst.java

private void setup(Class<? extends WebDriver> driverClass) {
    if (driverClass.equals(FirefoxDriver.class)) {
        driver = new FirefoxDriver();

    } else if (driverClass.equals(ChromeDriver.class)) {
        String chromedriver = null;
        if (SystemUtils.IS_OS_MAC || SystemUtils.IS_OS_LINUX) {
            chromedriver = "chromedriver";
        } else if (SystemUtils.IS_OS_WINDOWS) {
            chromedriver = "chromedriver.exe";
        }/*from   w  ww . j  a  va2  s  .c o m*/
        System.setProperty("webdriver.chrome.driver",
                new File("target/webdriver/" + chromedriver).getAbsolutePath());
        ChromeOptions options = new ChromeOptions();
        driver = new ChromeDriver(options);
    }
}

From source file:com.cloud.utils.net.NetUtils.java

public static String getDefaultEthDevice() {
    if (SystemUtils.IS_OS_MAC) {
        final String defDev = Script.runSimpleBashScript(
                "/sbin/route -n get default 2> /dev/null | grep interface | awk '{print $2}'");
        return defDev;
    }/*from  w ww.  j  a  v a  2  s .c  om*/
    final String defaultRoute = Script.runSimpleBashScript("/sbin/route | grep default");

    if (defaultRoute == null) {
        return null;
    }

    final String[] defaultRouteList = defaultRoute.split("\\s+");

    if (defaultRouteList.length != 8) {
        return null;
    }

    return defaultRouteList[7];
}

From source file:com.igormaznitsa.sciareto.ui.UiUtils.java

private static void showURLExternal(@Nonnull final URL url) {
    if (Desktop.isDesktopSupported()) {
        final Desktop desktop = Desktop.getDesktop();
        if (desktop.isSupported(Desktop.Action.BROWSE)) {
            try {
                desktop.browse(url.toURI());
            } catch (Exception x) {
                LOGGER.error("Can't browse URL in Desktop", x);
            }/*from w  w w  .  ja v a2 s  .  com*/
        } else if (SystemUtils.IS_OS_LINUX) {
            final Runtime runtime = Runtime.getRuntime();
            try {
                runtime.exec("xdg-open " + url);
            } catch (IOException e) {
                LOGGER.error("Can't browse URL under Linux", e);
            }
        } else if (SystemUtils.IS_OS_MAC) {
            final Runtime runtime = Runtime.getRuntime();
            try {
                runtime.exec("open " + url);
            } catch (IOException e) {
                LOGGER.error("Can't browse URL on MAC", e);
            }
        }
    }

}