Java System Properties
import java.util.Enumeration;
import java.util.Properties;
public class SystemProperties {
public static void main(String[] args) {
Properties props = System.getProperties();
// Enumerate all system properties
Enumeration enum0 = props.propertyNames();
for (; enum0.hasMoreElements();) {
// Get property name
String propName = (String) enum0.nextElement();
// Get property value
String propValue = (String) props.get(propName);
System.out.println(propName + ": value=" + propValue + ";");
// Get a system property
String dir = System.getProperty("user.dir");
String os = System.getProperty("os.name");
}
}
}
/* Output:
java.runtime.name: Java(TM) 2 Runtime Environment, Standard Edition;
sun.boot.library.path: C:\Program Files\Java\jre1.5.0_06\bin;
java.vm.version: 1.5.0_06-b05;
java.vm.vendor: Sun Microsystems Inc.;
java.vendor.url: http://java.sun.com/;
path.separator: ;;
java.vm.name: Java HotSpot(TM) Client VM;
file.encoding.pkg: sun.io;
user.country: US;
sun.os.patch.level: Service Pack 2;
java.vm.specification.name: Java Virtual Machine Specification;
user.dir: C:\jinjava\testjdk50;
java.runtime.version: 1.5.0_06-b05;
java.awt.graphicsenv: sun.awt.Win32GraphicsEnvironment;
java.endorsed.dirs: C:\Program Files\Java\jre1.5.0_06\lib\endorsed;
os.arch: x86;
java.io.tmpdir: C:\DOCUME~1\jin\LOCALS~1\Temp\;
line.separator:
;
java.vm.specification.vendor: Sun Microsystems Inc.;
user.variant: ;
os.name: Windows XP;
sun.jnu.encoding: Cp1252;
java.library.path: C:\Program Files\Java\jre1.5.0_06\bin;.;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\PROGRA~1\IBM\SQLLIB\BIN;C:\PROGRA~1\IBM\SQLLIB\FUNCTION;C:\PROGRA~1\IBM\SQLLIB\SAMPLES\REPL;c:\j2sdk1.4.2\bin;
java.specification.name: Java Platform API Specification;
java.class.version: 49.0;
sun.management.compiler: HotSpot Client Compiler;
os.version: 5.1;
user.home: C:\Documents and Settings\jin;
user.timezone: ;
java.awt.printerjob: sun.awt.windows.WPrinterJob;
file.encoding: Cp1252;
java.specification.version: 1.5;
user.name: jin;
java.class.path: C:\jinjava\testjdk50;
java.vm.specification.version: 1.0;
sun.arch.data.model: 32;
java.home: C:\Program Files\Java\jre1.5.0_06;
java.specification.vendor: Sun Microsystems Inc.;
user.language: en;
awt.toolkit: sun.awt.windows.WToolkit;
java.vm.info: mixed mode;
java.version: 1.5.0_06;
java.ext.dirs: C:\Program Files\Java\jre1.5.0_06\lib\ext;
sun.boot.class.path: C:\Program Files\Java\jre1.5.0_06\lib\rt.jar;C:\Program Files\Java\jre1.5.0_06\lib\i18n.jar;C:\Program Files\Java\jre1.5.0_06\lib\sunrsasign.jar;C:\Program Files\Java\jre1.5.0_06\lib\jsse.jar;C:\Program Files\Java\jre1.5.0_06\lib\jce.jar;C:\Program Files\Java\jre1.5.0_06\lib\charsets.jar;C:\Program Files\Java\jre1.5.0_06\classes;
java.vendor: Sun Microsystems Inc.;
file.separator: \;
java.vendor.url.bug: http://java.sun.com/cgi-bin/bugreport.cgi;
sun.cpu.endian: little;
sun.io.unicode.encoding: UnicodeLittle;
sun.desktop: windows;
sun.cpu.isalist: ;
*/
0 Comments:
Post a Comment
<< Home