Operating System Information

In this example we are learn how we can get information about our operation system.

Operating System Information


In this example we are learn how we can get information about our operation system. In this example we are getting the OS name, its version and architecture of OS. We are using getProperty(String key)  to get the property of the OS. To get OS name we have key value os.name,to get version we have os.version and to get architecture we have os.orch

The System class contains several useful class fields and methods. It cannot be instantiated. 

The method and its keys:

String getProperty(String key):
This method is used to get the system property. 

S/No. Key Description
1 java.version The version of Java Runtime Environment.
2 java.vendor  The name of Java Runtime Environment vendor
3 java.vendor.url The URL of Java vendor
4 java.home The directory of Java installation 
5 java.vm.specification.version The specification version of Java Virtual Machine
6 java.vm.specification.vendor The name of specification vendor of Java Virtual Machine 
7 java.vm.specification.name Java Virtual Machine specification name
8 java.vm.version  JVM implementation version
9 java.vm.vendor JVM implementation vendor
10 java.vm.name  JVM  implementation name
11 java.specification.version  The name of specification version Java Runtime Environment 
12 java.specification.vendor  JRE specification vendor
13 java.specification.name  JREspecification name
14 java.class.version Java class format version number
15 ava.class.path Path of java class
16 java.library.path List of paths to search when loading libraries
17 java.io.tmpdir The path of temp file
18 java.compiler The Name of JIT compiler to use
19 java.ext.dirs The path of extension directory or directories
20 os.name  The name of OS name
21 os.arch  The OS architecture
22 os.version  The version of OS
23 file.separator The File separator
24 path.separator  The path separator 
25 line.separator The line separator
26 user.name The name of account name user
27 user.home The home directory of user 
28 user.dir  The current working directory of the user

The code of the program is given below:

public class OpertingSystemInfo 
  public static void main(String[] args)
  String nameOS = "os.name";  
  String versionOS = "os.version";  
  String architectureOS = "os.arch";
  System.out.println("\n  The information about OS");
  System.out.println("\nName of the OS: " 
  System.out.println("Version of the OS: " 
  System.out.println("Architecture of THe OS: " 

The output of the program is given below:

C:\convert\rajesh\completed>javac OpertingSystemInfo.java
C:\convert\rajesh\completed>java OpertingSystemInfo
    The information about OS
Name of the OS: Windows 2000
Version of the OS: 5.0
Architecture of The OS: x86

Download this example.