What is the system getProperties() method in Java?

The static function getProperties() is used to read the system properties. It also defines the recent system properties. The recent set of properties will be returned as the property’s object. If there is no recent set, the set of properties will be created and initialized. These properties also contain the values for the keys. Let’s discuss some of these keys.

Keys and Details

Keys

Details

version of

the version of java virtual machine JVM.

os.version

version of operating system.

path.separator

directory or path delimiter.

java.compiler

java compiler name which is being used.

file.separator

file delimiter.

java.home

java home installation directory.

os.name

name of operating system.

java.vm.version

java virtual machine vendor info.

java.vm.url

URL for vendor web resources.

java.runtime.name

runtime environment name

Syntax


public static Properties getProperties()

Parameters

NA: It does not take any arguments.

Return Value

This function will return the system properties.

  • It returns an instance of the Properties class.

The java.util.Properties class object contains key and value pair. Both these values are String type.

Example

The code regarding the getProperties() is shown below:

import java.lang.*;
import java.util.Properties;
// Main Class
public class EdPresso {
public static void main(String[] args) {
/* Using the getProperties() function
System class refers to the Java Virtual Machine that you are using to compile the java code.
the getProperties function finds the exact properties
that Java virtual Machine on your system attains from your OS
*/
System.out.println("Here is the the JVM info regarding your OS :");
System.out.println();
// it is Property Object
Properties JVM1 = System.getProperties();
JVM1.list(System.out);
}
}

Free Resources