Tuesday, July 7, 2009

In Java, how to get the OS type and OS name

String osName=null;
// get OS type
try
{
String osType = System.getProperty("os.arch");
System.out.println("Operating system type => " + osType);
osName = System.getProperty("os.name");
System.out.println("Operating system type => " + osName);
}
catch (Exception e)
{
System.out.println("Exception caught =" + e.getMessage());
}

No comments: