Get OS-level system information

后端 未结 16 2113
情话喂你
情话喂你 2020-11-22 02:02

I\'m currently building a Java app that could end up being run on many different platforms, but primarily variants of Solaris, Linux and Windows.

Has anyone been abl

16条回答
  •  生来不讨喜
    2020-11-22 02:29

    One simple way which can be used to get the OS level information and I tested in my Mac which works well :

     OperatingSystemMXBean osBean =
            (OperatingSystemMXBean)ManagementFactory.getOperatingSystemMXBean();
        return osBean.getProcessCpuLoad();
    

    You can find many relevant metrics of the operating system here

提交回复
热议问题