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 void main(String[] args) {

    // prints the name of the system property
    System.out.println(System.getProperty("user.dir"));

    // prints the name of the Operating System
    System.out.println(System.getProperty("os.name"));

    // prints Java Runtime Version
    System.out.println(System.getProperty("java.runtime.version"));
}

From source file:MainClass.java

public static void main(String[] args) {

    File cwd = new File(System.getProperty("user.dir"));
    File[] htmlFiles = cwd.listFiles(new HTMLFileFilter());
    for (int i = 0; i < htmlFiles.length; i++) {
        System.out.println(htmlFiles[i]);
    }/*w  w w  . j av a 2 s  . c o  m*/
}

From source file:ShowUserDir.java

public static void main(String args[]) {
        System.out.println(System.getProperty("user.dir"));
    }

From source file:MainClass.java

public static void main(String[] args) throws Exception {
    String operatingSystem = (String) System.getProperty("os.name");
    String javaVersion = (String) System.getProperty("java.version");

    String javaDirectory = (String) System.getProperty("java.home");
    String userHomeDir = (String) System.getProperty("user.home");
    String myFile = (String) System.getProperty("myFile");
    FileInputStream fin = new FileInputStream(myFile);
}

From source file:Main.java

public static void main(String[] args) {

    System.setProperty("java.runtime.version", "Java Runtime 1.6.0");

    System.out.println(System.getProperty("java.runtime.version"));
}

From source file:PIMInstallTester.java

public static void main(String[] a) throws Exception {
    String version = null;// w w  w.  j a  va  2 s  .  c  om
    version = System.getProperty("microedition.pim.version");
    if (version != null) {
        if (!version.equals("1.0"))
            throw new IOException("Package is not version 1.0.");
    } else
        throw new IOException("PIM optional package is not available.");
}

From source file:MainClass.java

public static void main(String[] a) {
    String oldValue = System.clearProperty("java.class.path");
    System.setProperty("user.dir", "C:/MyProg");
    System.out.println(System.getProperty("user.dir"));
}

From source file:Main.java

public static void main(String[] args) {

    String s = System.clearProperty("java.class.path");

    System.setProperty("user.dir", "C:/java2s.com");

    System.out.println(System.getProperty("user.dir"));
}

From source file:Main.java

public static void main(String[] args) {
    String name = "os.name";
    String version = "os.version";
    String architecture = "os.arch";

    System.out.println("Name: " + System.getProperty(name));
    System.out.println("Version: " + System.getProperty(version));
    System.out.println("Architecture: " + System.getProperty(architecture));
}

From source file:CheckVersion.java

public static void main(String[] args) {
    String version = System.getProperty("java.version");
    char minor = version.charAt(2);
    char point = version.charAt(4);
    if (minor < '4' || point < '1')
        throw new RuntimeException("JDK 1.4.1 or higher " + "is required to run the examples in this book.");
    System.out.println("JDK version " + version + " found");
}