
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
Display Operating System Name in Java
Use the System.getProperty() method in Java to get the Operating System name.
It’s syntax is −
String getProperty(String key)
Above, the key is the name of the system property. Since, we want the OS name, therefore we will add the key as −
os.name
Example
public class Demo { public static void main(String[] args) { System.out.print("Operating System: "); System.out.println(System.getProperty("os.name")); } }
Output
Operating System: Linux
Advertisements