I am wondering if it is possible to get information (like memory usage) about a running process which can be normally seen in the Processes tab of the Windows Task Manager. If yes, is there any way of doing it, using java?
Asked
Active
Viewed 342 times
2
-
3This might be helpful. It has a lot of information and links http://stackoverflow.com/questions/25552/using-java-to-get-os-level-system-information – RNJ Sep 13 '12 at 08:34
1 Answers
2
Windows has a command called tasklist
that gives you
Image Name PID Session Name Session# Mem Usage
You can use a Runtime.getRuntime().exec("tasklist.exe")
to read that information.
Something like this:
Process process = Runtime.getRuntime().exec("tasklist.exe");
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
String line;
while((line = reader.readLine()) != null){
System.out.println(line);
}

Sujay
- 6,753
- 2
- 30
- 49
-
@Ameoo: glad to help :) However, you might also want to look at [SIGAR APIs](http://support.hyperic.com/display/SIGAR/Home) as well – Sujay Sep 13 '12 at 08:59