Search This Blog

Showing posts with label information. Show all posts
Showing posts with label information. Show all posts

How to Get Operating System Information in Java

Using java, you can gather some information about the operating system of the computer system on which the code is running. That us java provides some API classes that will help you to know about the operating system of the computer on which your application program is running. You can use System.getProperty() method for this purpose. There are some system property keys (strings) which can be used to get the respective information. The parameter to the System.getProperty() method is a string, the property key. The following values for the parameter string will give operating system related informations.

"os.arch"
Operating system architecture

"os.name"
Name of the operating system.

"os.version"
Version of Operating system.

Usage examples:

The following java program displays the Operating system related informations using getProperty() method.
System.out.println("Operating system architecture:"+System.getProperty("os.arch") ); System.out.println("Operating system Name:"+System.getProperty("os.name") ); System.out.println("Operating system version:"+System.getProperty("os.version") );