How can I get memory and CPU usage of an external process with Java?

时光怂恿深爱的人放手 提交于 2019-12-12 01:26:56

问题


I need to get info for memory and CPU usage of some process running on the machine (not the Java process).

How can I do that?


回答1:


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.




回答2:


If I'm not mistaken Runtime.getRuntime is for the virtual machine and not the physical. What you are about asking is getting the physical machine information (meaning the CPU).



来源:https://stackoverflow.com/questions/7377271/how-can-i-get-memory-and-cpu-usage-of-an-external-process-with-java

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!