This content has been marked as final. Show 4 replies
One possibility is to use ProcessBuilder to execute
"tasklist /FO CSV"
and then parse the 'stdout'. You might find the CPU time resolution too small for you but ...
Note - you should read the 4 sections of http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html and implement ALL the recommendations. Though the article is written round Runtime.exec() the traps apply to the Process object however it is created.
i guess jniwrapper libs allow you to do such thing. however it will be native impl and jni calls.
on a side note, do consider # of processors as well. these days most of the machines will have multiple cores.
Edited by: BIJ001 on 27-May-2011 05:39
you might want to check out the SIGAR library, http://support.hyperic.com/display/SIGAR/Home . we were looking for functionality like this and came across this library. in the testing i did, it seemed to work great, although we never ended up implementing the features which required it, so i never actually used it for real.