如何使用Java获得外部进程的内存和CPU使用率? [英] How can I get memory and CPU usage of an external process with Java?
本文介绍了如何使用Java获得外部进程的内存和CPU使用率?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要获取有关计算机上运行的某些进程(而不是Java进程)的内存和CPU使用率的信息.
I need to get info for memory and CPU usage of some process running on the machine (not the Java process).
我该怎么做?
推荐答案
它是平台相关的,但实际上使用Runtime.getRuntime()
执行适当的命令,捕获其输出并解析为所需的数据.
It's platform dependent, but essentially use Runtime.getRuntime()
to execute the appropriate command, capture its output and parse it for the data you need.
这篇关于如何使用Java获得外部进程的内存和CPU使用率?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文