
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
System.getProperty() in Java
The getProperty(String key) method in Java is used to returns the system property denoted by the specified key passed as its argument.It is a method of the java.lang.System Class.
Declaration − The java.lang.System.getProperty(String key) is declared as follows −
public static String getProperty(String key)
where key is the name of the System property.
Some values of the key are as follows −
- file.separator
- java.specification.version
- java.vm.version
- java.class.path
- java.vendor
- java.class.version
- os.arch
- java.compiler
- line.separator
- java.version
- java.vendor.url
- os.name
Let us see a program showing the use of getProperty() method in Java −
Example
public class Example { public static void main(String[] args) { System.out.println("System property: " + System.getProperty("user.dir")); System.out.println("Operating System: " + System.getProperty("os.name")); System.out.println("Java runtime version: " + System.getProperty("java.runtime.version" )); } }
Output
System property: /home/cg/root/5182567 Operating System: Linux Java runtime version: 1.8.0_141-b16
Advertisements