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

后端 未结 11 2670
粉色の甜心
粉色の甜心 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:31

    For disk space, if you have Java 6, you can use the getTotalSpace and getFreeSpace methods on File. If you're not on Java 6, I believe you can use Apache Commons IO to get some of the way there.

    I don't know of any cross platform way to get CPU usage or Memory usage I'm afraid.

提交回复
热议问题