Get OS Information using Java

In this tutorial, We will show you to write program about, How to Get OS Information using Java. The example java program were tested with environment and output is shared in the same post.

The following OSInformation class used to get information such as OS Name, OS Version, and OS Architecture etc. In Java we have predefined API`s and methods to get those information using java.lang.System.getProperty(key). by passing the appropriate key we can able to get the value accordingly. You find the sample java program below.

package com.dineshkrish.util;
public class OSInformation {
public static void main(String[] args) {
String os_name = System.getProperty("");
String os_version = System.getProperty("os.version");
String os_arch = System.getProperty("os.arch");
System.out.println("OS Information");
System.out.println("OS Name : "+os_name);
System.out.println("OS Version : "+os_version);
System.out.println("OS Architecture : "+os_arch);



OS Information
OS Name : Windows 8.1
OS Version : 6.3
OS Architecture : x86


No responses yet

Leave a Reply

Your email address will not be published. Required fields are marked *