How do I programmatically determine operating system in Java?

后端 未结 19 2917
眼角桃花
眼角桃花 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条回答
  •  Happy的楠姐
    2020-11-22 05:13

    This code for displaying all information about the system os type,name , java information and so on.

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Properties pro = System.getProperties();
        for(Object obj : pro.keySet()){
            System.out.println(" System  "+(String)obj+"     :  "+System.getProperty((String)obj));
        }
    }
    

提交回复
热议问题