How do I monitor the computer's CPU, memory, and disk usage in Java?

后端 未结 11 2654
粉色の甜心
粉色の甜心 2020-11-22 13:02

I would like to monitor the following system information in Java:

  • Current CPU usage** (percent)
  • Available memory* (free/total)
  • Available d

11条回答
  •  清酒与你
    2020-11-22 13:16

    The accepted answer in 2008 recommended SIGAR. However, as a comment from 2014 (@Alvaro) says:

    Be careful when using Sigar, there are problems on x64 machines... Sigar 1.6.4 is crashing: EXCEPTION_ACCESS_VIOLATION and it seems the library doesn't get updated since 2010

    My recommendation is to use https://github.com/oshi/oshi

    Or the answer mentioned above.

提交回复
热议问题