Wednesday, February 4, 2009

Get system properties using System class

package com.thanooj;

import java.util.Properties;

public class GetSystemProperties {


public static void main(String[] args) {



Properties prop = System.getProperties();
System.out.println("Printing all System properties");

prop.list(System.out);
}
}

/* out put

Printing all System properties
-- listing properties --
java.runtime.name=Java(TM) 2 Runtime Environment, Stand...
sun.boot.library.path=C:\Program Files\MyEclipse 6.6\jre\bin
java.vm.version=1.5.0_11-b03
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.java.launcher=SUN_STANDARD
sun.os.patch.level=Service Pack 2
java.vm.specification.name=Java Virtual Machine Specification
user.dir=D:\Javapractice projects\TestJava
java.runtime.version=1.5.0_11-b03
java.awt.graphicsenv=sun.awt.Win32GraphicsEnvironment
java.endorsed.dirs=C:\Program Files\MyEclipse 6.6\jre\li...
os.arch=x86
java.io.tmpdir=C:\DOCUME~1\SEETHA~1\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\MyEclipse 6.6\jre\bi...
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\seetharam
user.timezone=
java.awt.printerjob=sun.awt.windows.WPrinterJob
file.encoding=Cp1252
java.specification.version=1.5
user.name=seetharam
java.class.path=D:\Javapractice projects\TestJava\Web...
java.vm.specification.version=1.0
sun.arch.data.model=32
java.home=C:\Program Files\MyEclipse 6.6\jre
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_11
java.ext.dirs=C:\Program Files\MyEclipse 6.6\jre\li...
sun.boot.class.path=C:\Program Files\MyEclipse 6.6\jre\li...
java.vendor=Sun Microsystems Inc.
file.separator=\
java.vendor.url.bug=http://java.sun.com/cgi-bin/bugreport...
sun.cpu.endian=little
sun.io.unicode.encoding=UnicodeLittle
sun.desktop=windows
sun.cpu.isalist=
*/

No comments: