Home Java Java-get-example Java example program to get the operating system's version
Questions:Ask|Latest

 
 

Share on Google+Share on Google+

Java example program to get the operating system's version

Advertisement
You can check your current system's operating system version by the java code also. For this purpose you have to use the System's property "os.version".

Java example program to get the operating system's version

     

java get OS version

You can check your current system's operating system version by the java code also. For this purpose you have to use the System's property "os.version". Its very simple to know your operating system's version in java. This program displays how one can use the System.getProperty() method to get Operating System Version.

In this example java program we have fetched the operating system's version by using the System.getProperty("os.version").

String osVersion= System.getProperty("os.version");

Above line of code gets the operating system's version and stores version in a string osVersion. Here is the full source code of GetOSVersion.java as follows:

GetOSVersion.java

import java.util.*;
import java.lang.*;
import java.net.*;

public class GetOSVersion
  {
  public static void main(String args[]) {
  try{
  String osVersion= System.getProperty("os.version");
  System.out.println("Operating system version =>"+ osVersion);
  }catch (Exception e){
  System.out.println("Exception caught ="+e.getMessage());
  }
  }
}

Output of our program :

C:\javaexamples>javac GetOSVersion.java

C:\javaexamples>java GetOSVersion
Operating system version =>5.0

Download Source Code

Advertisement

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: October 24, 2008

Related Tutorials

Ask Questions?    Discuss: Java example program to get the operating system's version  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments
holygenius3
April 20, 2011
Shutting down operating system

i need java codes to shut down my operating system
DMCA.com