I take it you're running Windows. Some versions come with an executable called "typeperf", which can report CPU utilization. You can execute it using Runtime.exec or ProcessBuilder, and then parse the results.
Some other tools were mentioned in this thread, but I think none of those reports CPU percentages. [ August 15, 2007: Message edited by: Ulf Dittmer ]
Running typeperf shouldn't present a problem, if it's available.
Joined: Apr 04, 2007
Hi, When I am trying to run typeperf through runtime.exec() it is giving error - ejava.io.IOException: Cannot run program "typeperf": CreateProcess error=2, The system cannot find the file specified. I guess typeperf is not available on machine so can you suggest how to download or use it?
Joined: Mar 22, 2005
As the thread linked above mentions, it's not part of all Windows versions. Microsoft's web site would be a good place to get some information about it.