Question

How can I tell the type of machine and OS my Java program is running on?

Answer

A set of system properties, accessible via the getSystemProperties() method of class System allows you to get all sorts of useful information.

class GetPropertyDemo
{
        public static void main(String args[])
        {
                // Display value for machine type and OS
                System.out.println ( System.getProperty("os.arch") + 
			" running " +
			System.getProperty("os.name") );
        }
}


Back