Home » Core Java » lang » System » Get system properties with System

About Ilias Tsagklis

Ilias Tsagklis
Ilias is a software developer turned online entrepreneur. He is co-founder and Executive Editor at Java Code Geeks.

Get system properties with System

With this example we are going to demonstrate how to get system properties. We are using the System class, that contains several useful class fields and methods. In short, to get system properties with System class you should:

  • Call getProperties() API method of System. This method determines the current system properties. It returns an object of the Properties class, that represents a persistent set of properties. The Properties can be saved to a stream or loaded from a stream. Each key and its corresponding value in the property list is a string.

Let’s take a look at the code snippet that follows:
 

package com.javacodegeeks.snippets.core;

import java.util.Properties;

public class GetSystemPropertiesWithSystem {
	
	public static void main(String[] args) {
		
		// Determines the current system properties
		Properties prop = System.getProperties();
		 
		prop.list(System.out);
		
	}

}

Output:

-- listing properties --
java.runtime.name=Java(TM) SE Runtime Environment
sun.boot.library.path=C:Program Files (x86)Javajdk1.6.0_...
java.vm.version=10.0-b19
java.vm.vendor=Sun Microsystems Inc.
java.vendor.url=http://java.sun.com/
...

 
This was an example of how to get system properties with System class in Java.

Do you want to know how to develop your skillset to become a Java Rockstar?

Subscribe to our newsletter to start Rocking right now!

To get you started we give you our best selling eBooks for FREE!

 

1. JPA Mini Book

2. JVM Troubleshooting Guide

3. JUnit Tutorial for Unit Testing

4. Java Annotations Tutorial

5. Java Interview Questions

6. Spring Interview Questions

7. Android UI Design

 

and many more ....

 

Receive Java & Developer job alerts in your Area

 

Leave a Reply

avatar

This site uses Akismet to reduce spam. Learn how your comment data is processed.

  Subscribe  
Notify of