Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Java Java-get-example Java example program to get Operating System type or architecture

Related Tutorials


 
 

Share on Google+Share on Google+

Java example program to get Operating System type or architecture

Advertisement
In java environment we can write java code which will make us enabled to get the operating system type.

Java example program to get Operating System type or architecture

     

java get OS type

In java environment we can write java code which will make us enabled to get the operating system type. We can get the operating system architecture or system type by using the system property.

Here this java example code displays how one can get the current running operating system's type. The property "os.arch" gives operating system version that you are running. We can get this property's value by using the method getProperty() of the java.lang.System .

Here is the full code of GetOSArchitecture.java is as follows:

GetOSArchitecture.java

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

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

Output:

C:\javaexamples>javac GetOSArchitecture.java

C:\javaexamples>java GetOSArchitecture
Operating system type =>x86

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

Discuss: Java example program to get Operating System type or architecture  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0
DMCA.com