Erik Sapir
Erik Sapir

Reputation: 24717

How can I get memory and CPU usage of an external process with Java?

I need to get info for memory and CPU usage of some process running on the machine (not the Java process).

How can I do that?

Upvotes: 1

Views: 1730

Answers (2)

sara brown
sara brown

Reputation: 9

If I'm not mistaken Runtime.getRuntime is for the virtual machine and not the physical. What you are about asking is getting the physical machine information (meaning the CPU).

Upvotes: 0

Bohemian
Bohemian

Reputation: 425003

It's platform dependent, but essentially use Runtime.getRuntime() to execute the appropriate command, capture its output and parse it for the data you need.

Upvotes: 2

Related Questions