System Properties in java
There are various system properties that we can use in our programs to perform some action or access some file.
There are some commonly used properties.
Key | Meaning |
“file.separator” | Character that separates components of a file path. This is “/” on UNIX and “” on Windows. |
“java.class.path” | Path used to find directories and JAR archives containing class files. Elements of the class path are separated by a platform-specific character specified in the path.separator property. |
“java.home” | Installation directory for Java Runtime Environment (JRE) |
“java.vendor” | JRE vendor name |
“java.vendor.url” | JRE vendor URL |
“java.version” | JRE version number |
“line.separator” | Sequence used by operating system to separate lines in text files |
“os.arch” | Operating system architecture |
“os.name” | Operating system name |
“os.version” | Operating system version |
“path.separator” | Path separator character used in java.class.path |
“user.dir” | User working directory |
“user.home” | User home directory |
“user.name” | User account name |
Example:- These are following keys that can be used to find out the property.
“System” class has a properties Object associated with it that is used to find out those properties.
For More Refer:-
http://docs.oracle.com/javase/tutorial/essential/environment/sysprop.html
Here is a small snippet that can show all you available properties
public class SystemProperties {
public static void main(String[] args) {
System.getProperties().entrySet().forEach(e -> {
System.out.println(e.getKey() + " : " + e.getValue());
});
}
}