Java Coding Nerd. This Blog will feature content-rich articles, tutorials and own opinions on variuos programming related topcis.

Java Misc

Java: How to gather System Properties

Asynchronus REST-Calls LocalDateTimeConverter

Asynchronus REST-Calls LocalDateTimeConverter

How to gather System Properties using Java

In this post we will learn what system properties we can read using Java.
To do this, we will code a method that will print all the system information using a foreach loop.

import java.util.Properties;
import java.util.Set;

public class SystemProps {

public static void main(String[] args) {

//Properties inherits form Hashtable and holds the
//Information of what the Propertie is called (key)
//and what the Propertie really is (value)
Properties props = System.getProperties();

//We want to loop through the entrys using the Keyset
Set<Object> propKeySet = props.keySet();

for (Object singleKey : propKeySet) {

System.out.println(singleKey += props.getProperty((String) singleKey));

And that is all. You can see your Props shining on your console.
Thanks for reading.

Spread the love

Leave a Reply

Theme by Anders Norén