获取系统属性值
public static void main(String[] args) {
Properties properties = System.getProperties();
Set<String> keys = properties.stringPropertyNames();
Object[] objects = keys.toArray();
for (int i = 0; i <objects.length ; i++) {
String key=(String) objects[i];
String value = properties.getProperty(key);
System.out.println(key+"===="+value);
}
String javaHome = properties.getProperty("java.home");
System.out.println("java_home目录是 "+javaHome);
String osName = properties.getProperty("os.name");
String osVersion = properties.getProperty("os.version");
System.out.println("系统版本:"+osName+" "+osVersion+" 版 ");
public static void main(String[] args) {
Properties properties = System.getProperties();
Set<String> keys = properties.stringPropertyNames();
for(String key:keys){
String value = properties.getProperty(key);
System.out.println(key+"--------="+value);
}
String javaHome = properties.getProperty("java.home");
System.out.println("java_home目录是 "+javaHome);
String osname = properties.getProperty("os.name");
String osVer = properties.getProperty("os.version");
System.out.println("系统版本:"+osname+" "+osVer+" 版 ");
}
勤學如春起之苗,不見其增,日有所長。綴學如磨刀之石,不見其損,日有所虧。