There was a need to
determine the OS on which my application is running. So come across system
properties method in java. Sharing the same with you..
/**
* I could able to get
below properties..!!
java.runtime.name, sun.boot.library.path,
java.vm.version, java.vm.vendor,
java.vendor.url, path.separator, java.vm.name,
file.encoding.pkg,
user.country, user.script,
sun.java.launcher, sun.os.patch.level,
java.vm.specification.name, user.dir,
java.runtime.version,
java.awt.graphicsenv, java.endorsed.dirs, os.arch, java.io.tmpdir,
line.separator, java.vm.specification.vendor,
user.variant,
os.name, sun.jnu.encoding, java.library.path,
java.specification.name,
java.class.version, sun.management.compiler, os.version,
user.home,
user.timezone, java.awt.printerjob,
file.encoding,
java.specification.version, java.class.path,
user.name,
java.vm.specification.version,
sun.java.command, java.home,
sun.arch.data.model, user.language,
java.specification.vendor,
awt.toolkit, java.vm.info, java.version, java.ext.dirs,
sun.boot.class.path,
java.vendor, file.separator, java.vendor.url.bug, sun.io.unicode.encoding,
sun.cpu.endian, sun.desktop, sun.cpu.isalist
*/
@SuppressWarnings("rawtypes")
private static void
printSystemProperties(){
Properties
properties=System.getProperties();
String
key;
Enumeration
keys=properties.keys();
while(keys.hasMoreElements()){
key=(String)keys.nextElement();
System.out.println("\n");
System.out.println("key
:"+key);
System.out.println("value
:"+properties.getProperty(key));
}
}
Happy coding :)