- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Java Program to get Operating System name and version
Use the System.getProperty() method in Java to get the Operating System name and version.
It’s syntax is −
String getProperty(String key)
Above, the key is the name of the system property. Since, we want the OS name and version, therefore we will add the key as −
Operating System name - os.name Operating System version - os.version
The following is an example −
Example
public class Demo { public static void main(String []args){ System.out.println("OS Name: " + System.getProperty("os.name")); System.out.println("OS Version: " + System.getProperty("os.version")); } }
Output
OS Name: Linux OS Version: 3.10.0-862.9.1.el7.x86_64
Advertisements