使用Java检索Window进程的CPU使用情况 [英] Using Java to retrieve the CPU Usage for Window's Processes

查看:172
本文介绍了使用Java检索Window进程的CPU使用情况的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种Java解决方案来查找Windows中正在运行的进程的CPU使用情况。浏览网页后,似乎没有关于Java解决方案的信息。请记住,我不是要查找JVM的CPU使用情况,而是查找当时在Windows中运行的任何进程。

I am looking for a Java solution to finding the CPU usage for a running process in Windows. After looking around the web, there seems to be little information on a solution in Java. Keep in mind, I am not looking to find the CPU usage for the JVM, but any process running in Windows at the time.

我能够检索内存使用情况在Java中使用exec(tasklist.exe ...)来检索和解析进程信息。虽然每个进程都有一个聚合CPU周期计时器,但我看不到CPU使用率列。

I am able to retrieve the memory usage in Java by using the exec("tasklist.exe ... ") to retrieve and parse process information. Although there is an aggregate CPU cycle timer for each process, I do not see a CPU usage column.

非常感谢任何帮助。另外,如果可能的话,我想远离C库;但是,如果没有其他选择,通过这种方式的解决方案是合适的。

Any help would be greatly appreciated. Also, if possible, I would like to stay away from C libraries; however, if there is no other alternative, a solution by that means would be appropriate.

非常感谢,

Steve

推荐答案

如果GPL许可API适用于您,请试用

If a GPL licensed API is fine for you, try out

SIGAR - 系统信息收集者和记者

它允许访问您想要的信息(以及更多),并在许多相关平台上得到支持

It allows access to the info you want (and much more) and is supported on many relevant platforms

这篇关于使用Java检索Window进程的CPU使用情况的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆