Example usage for java.lang System getProperty

List of usage examples for java.lang System getProperty

Introduction

In this page you can find the example usage for java.lang System getProperty.

Prototype

public static String getProperty(String key) 

Source Link

Document

Gets the system property indicated by the specified key.

Usage

From source file:Main.java

public static String removeLineBreaks(String str) {
    return str.replace(System.getProperty("line.separator"), " ");
}

From source file:Main.java

/** Returns true if the underlying OS is Mac OS irrespective of SWT */
public static boolean osIsMacOSX() {
    return System.getProperty("os.name").indexOf("Mac OS") != -1;
}

From source file:Main.java

private static boolean isYunOS() {
    try {/*from ww w .ja  va  2s  .  c  o m*/
        String version = System.getProperty("ro.yunos.version");
        String vmName = System.getProperty("java.vm.name");
        return (vmName != null && vmName.toLowerCase().contains("lemur"))
                || (version != null && version.trim().length() > 0);
    } catch (Exception ignore) {
        return false;
    }
}

From source file:Main.java

static File getDefaultGameDir() {
    String os = System.getProperty("os.name").toLowerCase();
    String baseDir = null;/*from w  w  w . j  a  va2  s.c o  m*/
    String subDir = ".minecraft";

    if (os.contains("win")) {
        baseDir = System.getenv("APPDATA");
    } else if (os.contains("mac")) {
        subDir = "Library/Application Support/minecraft";
    }

    if (baseDir == null) {
        baseDir = System.getProperty("user.home");
    }

    return new File(baseDir, subDir);
}

From source file:Main.java

public static String getOS() {
    return System.getProperty("os.name").toLowerCase();
}

From source file:Main.java

public static String getCpuInfo() {
    try {/*from  www .j  ava2 s  .  c  o m*/
        String arc = System.getProperty("os.arch").toUpperCase();
        if (arc.startsWith("ARM")) {
            arc = "ARM";
        } else if (arc.startsWith("MIPS")) {
            arc = "MIPS";
        } else if (arc.startsWith("X86") || arc.endsWith("86")) {
            arc = "X86";
        } else {
            arc = "ARM";
        }
        return arc;
    } catch (Exception e) {
        return "ARM";
    }
}

From source file:Util.java

public static String[] getJVMInfo() {
    return new String[] { //
            "Virtual Machine Information (JVM)", //
            "JVM Name: " + System.getProperty("java.vm.name"), //
            "JVM installation directory: " + System.getProperty("java.home"), //
            "JVM version: " + System.getProperty("java.vm.version"), //
            "JVM Vendor: " + System.getProperty("java.vm.vendor"), //
            "JVM Info: " + System.getProperty("java.vm.info"), //
    };// ww  w.  j  a  v  a  2s .  com
}

From source file:Util.java

public static String[] getJREInfo() {
    return new String[] { //
            "Java Platform Information", //
            "Java Runtime  Name: " + System.getProperty("java.runtime.name"), //
            "Java Version: " + System.getProperty("java.version"), //
            "Java Class Version: " + System.getProperty("java.class.version"), //
    };//from   w w w . j  av  a2s. c  om
}

From source file:Utils.java

public static String fixLineSeparator(String xml) throws UnsupportedEncodingException {
    if ("\r\n".equals(System.getProperty("line.separator"))) {
        xml = xml.replaceAll("\r[^\n]", System.getProperty("line.separator"));
    } else {/*from ww w .j ava  2  s  . c  om*/
        xml = xml.replaceAll("\r\n", System.getProperty("line.separator"));
    }

    return xml;
}

From source file:Main.java

public static File toolsJar() {
    final String jdkLocation = System.getProperty("java.home");
    final File javaHome = new File(jdkLocation);
    try {//w w  w .  j  a va 2  s  . c om
        return new File(javaHome, "../lib/tools.jar").getCanonicalFile();
    } catch (final IOException e) {
        throw new RuntimeException(e);
    }
}