Bootstrap FreeKB - Java - Print system properties
Java - Print system properties

Updated:   |  Java articles

The following class will print all of the system properties.

import java.util.Properties;

public class Main {

  public static void main(String[] args) {

    Properties properties = System.getProperties();
    System.out.println(properties);

  }
}

 

Or, you can return a specific system property.

import java.util.Properties;

public class Main {

  public static void main(String[] args) {

    String properties = System.getProperty("java.runtime.name");
    System.out.println(properties);

  }
}

 

Or you can loop through each property, printing the key value pair.

import java.util.Properties;

public class Main {

  public static void main(String[] args) {

    Properties properties = System.getProperties();
    for (Map.Entry<Object, Object> set : properties.entrySet()) { 
      System.out.println( set.getKey() + " = " + set.getValue() ); 
    }

  }
}

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter 32347a in the box below so that we can be sure you are a human.