How do I get operating system name and version?

Category: java.lang, viewed: 1688 time(s).
 
package org.kodejava.example.java.lang;
 
public class OpertingSystemInfo 
{
    public static void main(String[] args)
    {
        // The key for getting operating system name
        String name = "os.name";        
        // The key for getting operating system version
        String version = "os.version";        
        // The key for getting operating system architecture
        String architecture = "os.arch";
        
        System.out.println("Name: " + System.getProperty(name));
        System.out.println("Version: " + System.getProperty(version));
        System.out.println("Architecture: " + System.getProperty(architecture));
    }
}
 
 

Below is the example result of our program, of course it could be different from what you'll see in your machine because it depends on the operating system that you use.

Name: Windows XP
Version: 5.1
Architecture: x86
Bookmark this example!  

Most Viewed Examples

Google

100 Top & Latest


eXTReMe Tracker
visitor stats