How do I programmatically determine operating system in Java?

后端 未结 19 2527
眼角桃花
眼角桃花 2020-11-22 04:56

I would like to determine the operating system of the host that my Java program is running programmatically (for example: I would like to be able to load different propertie

19条回答
  •  渐次进展
    2020-11-22 05:27

    Just use com.sun.javafx.util.Utils as below.

    if ( Utils.isWindows()){
         // LOGIC HERE
    }
    

    OR USE

    boolean isWindows = OSInfo.getOSType().equals(OSInfo.OSType.WINDOWS);
           if (isWindows){
             // YOUR LOGIC HERE
           }
    

提交回复
热议问题