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

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

Introduction

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

Prototype

boolean IS_OS_UNIX

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

Click Source Link

Document

Is true if this is a UNIX like system, as in any of AIX, HP-UX, Irix, Linux, MacOSX, Solaris or SUN OS.

Usage

From source file:Example6.java

public static void main(String[] args) throws IOException, InterruptedException {
    //check if the executable exists
    File file = new File("./examples/dtlz2_socket.exe");

    if (!file.exists()) {
        if (!SystemUtils.IS_OS_UNIX) {
            System.err.println(/*  www . ja va  2  s. c o  m*/
                    "This example only works on POSIX-compliant systems; see the Makefile for details");
            return;
        }

        System.err.println("Please compile the executable by running make in the ./examples/ folder");
        return;
    }

    //run the executable and wait one second for the process to startup
    new ProcessBuilder(file.toString()).start();
    Thread.sleep(1000);

    //configure and run the DTLZ2 function
    NondominatedPopulation result = new Executor().withProblemClass(MyDTLZ2.class).withAlgorithm("NSGAII")
            .withMaxEvaluations(10000).run();

    //display the results
    System.out.format("Objective1  Objective2%n");

    for (Solution solution : result) {
        System.out.format("%.4f      %.4f%n", solution.getObjective(0), solution.getObjective(1));
    }
}

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  w  w  w.j av a2s . c om
        }

        return serviceController;
    }
}

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

public static boolean isUnix() {
    return SystemUtils.IS_OS_UNIX;
}

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//  ww w .j  a va2  s .  c  om
        throw new IOException(NOT_SUPPORTED_ERROR);
    return run(commandLine);
}

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

public static Integer forceKill(Number pid) throws IOException, InterruptedException {
    if (pid == null)
        return null;
    final String commandLine;
    if (SystemUtils.IS_OS_UNIX)
        commandLine = "kill -9 " + pid;
    else if (SystemUtils.IS_OS_WINDOWS)
        commandLine = "taskkill /F /PID " + pid;
    else// w w w.  j ava 2s.c o  m
        throw new IOException(NOT_SUPPORTED_ERROR);
    return run(commandLine);
}

From source file:com.net2plan.utils.HTMLUtils.java

/**
 * Opens a browser for the given {@code URI}. It is supposed to avoid issues with KDE systems.
 *
 * @param uri URI to browse//from   w ww  .  j  a v a 2 s  .c  o  m
 */
public static void browse(URI uri) {
    try {
        if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) {
            Desktop.getDesktop().browse(uri);
            return;
        } else if (SystemUtils.IS_OS_UNIX
                && (new File("/usr/bin/xdg-open").exists() || new File("/usr/local/bin/xdg-open").exists())) {
            new ProcessBuilder("xdg-open", uri.toString()).start();
            return;
        }

        throw new UnsupportedOperationException(
                "Your operating system does not support launching browser from Net2Plan");
    } catch (IOException | UnsupportedOperationException e) {
        throw new RuntimeException(e);
    }
}

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

public static Boolean isRunning(Number pid) throws IOException, InterruptedException {
    if (pid == null)
        return null;
    final String commandLine;
    if (SystemUtils.IS_OS_UNIX)
        commandLine = "kill -0 " + pid;
    else//from   www . j a v  a 2  s  . c o  m
        throw new IOException(NOT_SUPPORTED_ERROR);
    Integer res = run(commandLine);
    if (res == null)
        return null;
    return res == 0;
}

From source file:com.o2d.pkayjava.editor.splash.SplashStarter.java

public SplashStarter(SplashScreen.SplashListener listener) {

    if (SystemUtils.IS_OS_MAC_OSX || SystemUtils.IS_OS_MAC || SystemUtils.IS_OS_UNIX) {
        // let's work out osx splash screen later, not sure if we can have translucency there.
        listener.loadingComplete();//from   ww  w  . j  a  va  2 s.c  o m
        return;
    }

    splashScreen = new SplashScreen();
    LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
    config.fullscreen = false;
    config.width = 467;
    config.height = 415;
    config.resizable = false;
    splashFrame = new SplashFrame(splashScreen, config);
    /*
    GraphicsEnvironment ge =
        GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice gd = ge.getDefaultScreenDevice();
    boolean isUniformTranslucencySupported = gd.isWindowTranslucencySupported(TRANSLUCENT);
    boolean isPerPixelTranslucencySupported = gd.isWindowTranslucencySupported(PERPIXEL_TRANSLUCENT);
    boolean isShapedWindowSupported = gd.isWindowTranslucencySupported(PERPIXEL_TRANSPARENT);
    */

    splashScreen.listener = listener;
}

From source file:com.netflix.genie.web.util.UnixProcessCheckerTest.java

/**
 * Setup for the tests./*from w ww .j a v  a  2 s  .  com*/
 */
@Before
public void setup() {
    Assume.assumeTrue(SystemUtils.IS_OS_UNIX);
    this.executor = Mockito.mock(Executor.class);
    this.tomorrow = Instant.now().plus(1, ChronoUnit.DAYS);
    // For standard tests this will keep it from dying
}

From source file:com.netflix.genie.core.util.UnixProcessCheckerUnitTests.java

/**
 * Setup for the tests.//w  w  w  .j  av  a  2s  .  co m
 */
@Before
public void setup() {
    Assume.assumeTrue(SystemUtils.IS_OS_UNIX);
    this.executor = Mockito.mock(Executor.class);
    final Calendar tomorrow = Calendar.getInstance();
    // For standard tests this will keep it from dying
    tomorrow.add(Calendar.DAY_OF_YEAR, 1);
    this.processChecker = new UnixProcessChecker(PID, this.executor, tomorrow.getTime());
}