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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
/* Get system properties using System class This example shows how to get system properties using System class. This example also shows how to get and print all system properties. */ import java.util.Properties; public class GetSystemProperties { public static void main(String[] args) { /* * To get system properties use, * static Properties getProperties() of System class. * * getProperties is a static method. * * Plase note that these properties are environment * specific. */ Properties prop = System.getProperties(); System.out.println("Printing all System properties"); /* * To print all system properties use * static void list(PrintStream ps) method of System * class. * * Hint : To print properties on console, paas * System.out to list method. */ prop.list(System.out); } } /* TYPICAL output would be like, Printing all System properties -- listing properties -- java.assistive=ON java.runtime.name=Java(TM) 2 Runtime Environment, Stand... java.vm.version=1.3.1 java.vm.vendor=IBM Corporation java.vendor.url=http://www.ibm.com/ path.separator=; java.vm.name=Classic VM .... */ |
Add Comment