/** * Check whether this is windows 9x, or windows NT and higher. */ public boolean isWin9x() { if (isWin9x == 0) { // let's see if this is windows 9x try { ProcessLauncher launcher = new ProcessLauncher(new String[] { "cmd", "/c", "echo" }); launcher.launch(); isWin9x = -1; } catch (ProcessLauncher.CommandNotExistsException nosuchcommand) { isWin9x = 1; } catch (Exception e) { logger.error("Unexpected exception while checking isWin9x", e); } } return isWin9x == 1; }
/** * Check whether this is windows 9x, or windows NT and higher. */ public boolean isWin9x() { if (isWin9x == 0) { // let's see if this is windows 9x try { ProcessLauncher launcher = new ProcessLauncher(new String[] { "cmd", "/c", "echo" }); launcher.launch(); isWin9x = -1; } catch (ProcessLauncher.CommandNotExistsException nosuchcommand) { isWin9x = 1; } catch (Exception e) { logger.error("Unexpected exception while checking isWin9x", e); } } return isWin9x == 1; }
launcher.launch(); String output = launcher.getStandardOutput();
/** * Opens applications by invoking 'kfmclient' that is part of KDE. */ @Override public int openWithDesktopEnvironment(String resource) throws UnsupportedOperationException, IOException { if (resource != null) { ProcessLauncher launcher = new ProcessLauncher(new String[] { "kfmclient", "exec", resource }, null); int exitValue = launcher.launch(); if (exitValue != 0) { logger.warn("Opening \"" + resource + "\" returned error code " + exitValue); } if (launcher.getStandardOutput().length() > 0) { logger.info(launcher.getStandardOutput()); } if (launcher.getErrorOutput().length() > 0) { logger.warn(launcher.getErrorOutput()); } return exitValue; } return -1; } }
/** * Open the resource by invoking the "open" command on the command line. */ @Override public int openResource(String resource) throws IOException { // bail out if nothing to open... if (resource != null) { // open works on file URI's too! :) ProcessLauncher launcher = new ProcessLauncher(new String[] { "open", resource }); int result = launcher.launch(); // show output from command if (launcher.getStandardOutput().length() > 0) { logger.info(launcher.getStandardOutput()); } if (launcher.getErrorOutput().length() > 0) { logger.warn(launcher.getErrorOutput()); } return result; } return -1; } }
int exitValue = launcher.launch();
int exitValue = launcher.launch();
return launcher.launch();
if (launcher.launch() == 0) { if (launcher.getStandardOutput().trim().length() > 0) { String output = launcher.getStandardOutput().trim();