-2

is there any builtIn library available in java to get the top 'n' cpu consuming process name and the percentage it's consuming.i want this program to work in any os such as windows,linux.

i tired with OperatingSystemMXBean but not sure this is the correct way and couldn't able to extract the necessary info.

3
  • 1
    As far as I am aware, there is no built-in library in Java that can provide this information across different operating systems. The reason is that the way processes and their CPU usage are managed is highly dependent on the operating system.
    – Hagelslag
    Commented Jul 9 at 12:34
  • I’m afraid not. The closest you can come is the totalCpuDuration() method of the ProcessHandle.Info class, but that isn’t the percentage of CPU being used.
    – VGR
    Commented Jul 9 at 12:35
  • You need to use native calls to the operating system to get this information. I'm sure this question has already been asked previously. have you searched Stack Overflow?.
    – aled
    Commented Jul 9 at 12:37

0

Browse other questions tagged or ask your own question.