Possible Duplicate:
java cpu usage monitoring
I'm trying to write a program in Java that can shutdown your computer when the computer hasn't been active (like CPU usage) for an amount of time.
I have written a program that can shutdown your pc (windows/mac/linux) after an amount of time. But i don't seem to find a way to check for the CPU usage or inactivity in JAVA.
Can anyone help me pls?
kind regards,
kdlannoy
I'm afraid you probably will have to find a native library. There doesn't appear to be any non-native way of acquiring the CPU usage, however there is support for finding memory usage and other usage indicators.
If you wanted to implement this yourself in a native way, you could look up what terminal command shows you your CPU usage, such as for linux you could execute the top command and then parse through Java.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With