Find operating system in java

by rajesh 2009-12-30 17:17:01

To find the operating system in which the java application is running we can just get the system property "os.name"

System.getProperty("os.name");

Example:

        String os = System.getProperty("os.name");


To check if it is windows, we can just check whether the name starts with WIN as
        if ( os != null && os.startsWith(WIN_ID))
            return true;

Tagged in:

1163
like
0
dislike
0
mail
flag

You must LOGIN to add comments