Determine operating system using System class - Java Native OS

Java examples for Native OS:OS

Description

Determine operating system using System class

Demo Code

 
public class Main {

  public static void main(String[] args) {
    String strOSName = System.getProperty("os.name");
    System.out.print("Get OS name example.. OS is ");
    if (strOSName != null) {
      if (strOSName.toLowerCase().indexOf("windows") != -1)
        System.out.println("Windows");
      else/* w ww  .j a  va  2s.co  m*/
        System.out.print("not windows");
    }
  }
}

Result


Related Tutorials