Print All System Properties Java

Print All System Properties Java

If you want to see all System properties including any of the properties set by you using java program please use below:

  • PrintAllSystemProperties.java:
import java.util.Enumeration;
import java.util.Properties;


public class PrintAllSystemProperties {
	
	@SuppressWarnings("unchecked")
	public static void main(String[] args) {
		
		System.setProperty("wells.ccu.clientconfig", "extend-access.xml");
		System.setProperty("wells.ccu.url", "http://techiworks.com/");
		System.setProperty("wells.cluster.extend.access", "true");
		System.setProperty("wells.ccu.serializer.config", "http://techiworks.com/");
		System.setProperty("tangosol.pof.enabled", "true");
		System.setProperty("tangosol.pof.config", "custom-types-pof-config.xml");
		System.setProperty("logging.dir", "./");
				
		//Print properties:	
		//Example 1
		Properties properties = System.getProperties();		
		properties.list(System.out);
		
		//Example 2
		
		System.out.println(properties);
		
		//Example 2
		Enumeration<String> enumeration = (Enumeration<String>) properties.propertyNames();
		
		while (enumeration.hasMoreElements()) {
			
			String propertyName = (String) enumeration.nextElement();
			String propertyValue = properties.getProperty(propertyName);
			System.out.println(propertyName + "=" + propertyValue);			
		}
	}

}

Reference:

Leave a Reply

Your email address will not be published. Required fields are marked *