Windows Task Manager : Processes

Hello Everybody,Can you please tell me, How to access the processes shown in Windows Task Manager?I need to save the list of the currently executing processes, Which javaclass can be used for it?Thanks!
[237 byte] By [Ritesh.Zealota] at [2007-11-26 18:04:35]
# 1

> Hello Everybody,

>

> Can you please tell me, How to access the processes

> shown in Windows Task Manager?

>

> I need to save the list of the currently executing

> processes, Which java

> class can be used for it?

>

> Thanks!

Hi,

You can't do that in pure java, you need to execute some native code.

Kaj

kajbja at 2007-7-9 5:35:00 > top of Java-index,Java Essentials,Java Programming...
# 2

This piece of code will ouput the list of processes to the ouput stream.

You can parse each line and take whatever you need.

Process p = Runtime.getRuntime().exec("tasklist");

BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream()));

String line = null;

while ((line = reader.readLine()) != null)

System.out.println(line);

Rodney_McKaya at 2007-7-9 5:35:00 > top of Java-index,Java Essentials,Java Programming...
# 3
Hi Rodney_McKay,Thanks for quick response.. :)
Ritesh.Zealota at 2007-7-9 5:35:00 > top of Java-index,Java Essentials,Java Programming...
# 4

Nope, not in java you don't...

By design the JVM divorces the programmer from platform specifics.

However, you could write a C/C++ program to emulate *nix's "ps -eaf" command on windows then then Runtime.exec("ps").

There's tonns of stuff on MSDN... just search for "enumerate process" in google, nineMSN (remember the deal with satan) or with MSDN's internal search.

You do have some interesting questions, don't you.

good luck... keith.

corlettka at 2007-7-9 5:35:00 > top of Java-index,Java Essentials,Java Programming...