Accessing System properties in Java(Operating System Feature)
Java programming language provides various properties support to access the environment details or system details. Below is the program to read all System Properties.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
//Reading System properties public class SystemPropertiesDemo { public static void main(String[] args) { String currentDir=System.getProperty("user.dir"); String javaVer=System.getProperty("java.version"); String os=System.getProperty("os.name"); String osArch=System.getProperty("os.arch"); String ioTempDir=System.getProperty("java.io.tmpdir"); System.out.println(currentDir); System.out.println(os); System.out.println(osArch); System.out.println(ioTempDir); } } |
1 2 3 4 5 6 7 8 9 10 11 12 |
/* Reading all properties */ import java.util.*; public class SystemAllProps { public static void main(String[] args) { Properties props=System.getProperties(); Set keys=props.keySet(); for (Object key : keys) { System.out.println(key+"--->"+System.getProperty(key.toString())); } } } |