How to get operating System information in java swing
- Saturday, July 3, 2010, 11:12
- Java
- Add a comment
|
|
You can check your operating system’s details by the java code.For this you have to use the built in properties “os.name” and “os.version”. on.name returns the name of operating system and on.version returns the version number.
Sample code for retrieving OS information:
{code codetype=php}
public class OSinfo
{
public static void main(String args[]) {
try{
String osName= System.getProperty(“os.name”);
String osVersion= System.getProperty(“os.version”);
System.out.println(“Operating system details =>”+ osName + osVersion);
}catch (Exception e){
System.out.println(“Exception caught =”+e.getMessage());
}
}
}{/code}
class OSinfo returns the OS name and version.


