How to retrieve System properties ?.
What are the properties has to be used while doing cross platform coding ?
We have to make use of almost all the properties comes from System.getProperties method for our development. While doing cross platform coding File.separator and path.separator and encoding are very well useful for us to get to know correct value.
Code Snippets to list out all the properties:
Properties props = System.getProperties();
Iterator it = (props.entrySet().iterator());
while (it.hasNext()) {
Map.Entry property =
(Map.Entry<String, String>) it.next();
System.out.println(property.getKey()
+ ": " + property.getValue());
}
In my machine, I got following properties key are set
java.runtime.name
sun.boot.library.path
java.vm.version
java.vm.vendor
java.vendor.url
path.separator
java.vm.name
file.encoding.pkg
sun.java.launcher
user.country
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
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
1 comment:
Thanks to show this.
Post a Comment