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.

Share on Google+Share on Google+

Operating System Information

Posted on: June 29, 2007 If you enjoyed this post then why not add us on Google+? Add us to your Circles



Discuss: Operating System Information   View All Comments

Post your Comment

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
Kumaran V. Ram
August 22, 2011

Thanks for the info. It was really helpful!
August 30, 2011

i want to create system that stores the username, logintime ,logouttime when user starts the computer with os linux or windos and stores data at database as per perticular username
January 19, 2012

In this example we are learn how we can get information about our operation system. There seems to be a grammatical error in this sentence. is there something that I missed. A part thats suppose to stick out?
Ahmed Adel
January 21, 2012

Very useful subject I like it and needed to know how to get the name of OS because some commands are not the the same on Linux and Windows like the commands of shutting down and rebooting the OS :)
January 27, 2012
How to get the file system details

Like in windows how we have file systems like 1. NTFS, 2. FTS, 3. CDFS(cd FileSystem when u insert CD in CD drive) how to get that information too
July 6, 2012
Will this wrk for Win7

Hi I have a doubt regarding the above example.... will this example work for Windows 7 Operationg system with Non Admin accoutn
July 11, 2012
need help

Hi, pls send me java code for 1. how to check which antivirus,antispyware, install on syste
December 24, 2012
operating sys information

Very goodh
December 4, 2012

thanks for os programme