I want to write a Java code which will print the System properties (whether machine's OS is windows or linux) on the machine it runs and store it in a variable.
Thanks in advance!
I want to write a Java code which will print the System properties (whether machine's OS is windows or linux) on the machine it runs and store it in a variable.
Thanks in advance!
You can use the following to get OS name:
System.getProperty("os.name");
To get a list (set) of all system properties you can use:
System.getProperties().entrySet();
and to print them use:
System.out.println(System.getProperty("os.name"));
//and
System.out.println(System.getProperties().entrySet().toString());