Return | Method | Summary |
---|---|---|
static String | clearProperty(String key) | Removes the system property. |
static String | getenv(String name) | Gets the value of the specified environment variable. |
static Properties | getProperties() | Determines the current system properties. |
static String | getProperty(String key) | Gets the system property. |
static String | getProperty(String key, String def) | Gets the system property. |
static void | setProperties(Properties props) | Sets the system properties to the Properties argument. |
static String | setProperty(String key, String value) | Sets the system property. |
The following properties are available:
public class Main {
public static void main(String args[]) {
System.setProperty("myKey", "myValue");
System.out.println(System.getProperty("myKey"));
}
}
The output:
myValue
Determine operating system using System class
public class Main {
public static void main(String[] args) {
String strOSName = System.getProperty("os.name");
if (strOSName != null) {
if (strOSName.toLowerCase().indexOf("windows") != -1)
System.out.println("Windows");
else
System.out.print("not windows");
}
}
}
Windows
java2s.com | Contact Us | Privacy Policy |
Copyright 2009 - 12 Demo Source and Support. All rights reserved. |
All other trademarks are property of their respective owners. |