All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.sikuli.natives.SysUtil Maven / Gradle / Ivy

There is a newer version: 2.0.5
Show newest version
/*
 * Copyright (c) 2010-2016, Sikuli.org, sikulix.com
 * Released under the MIT License.
 *
 */

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.sikuli.natives;

import java.lang.reflect.Constructor;

/**
 *
 * @author rhocke
 */
public class SysUtil {

  static OSUtil osUtil = null;

  static String getOSUtilClass() {
    String pkg = "org.sikuli.natives.";
    String os = System.getProperty("os.name").toLowerCase();
    if (os.startsWith("mac")) {
      return pkg + "MacUtil";
    } else if (os.startsWith("windows")) {
      return pkg + "WinUtil";
    } else {
      return pkg + "LinuxUtil";
    }
  }

  public static OSUtil getOSUtil() {
    if (osUtil == null) {
      try {
        Class c = Class.forName(SysUtil.getOSUtilClass());
        Constructor constr = c.getConstructor();
        osUtil = (OSUtil) constr.newInstance();
      } catch (Exception e) {
        System.out.println("[error] fatal: getOSUtil\n" + e.getMessage());
        System.exit(1);
      }
    }
    return osUtil;
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy