Getting running process list using java

by guruprasad 2014-04-10 10:36:59

To Get the running process list using java,

Function to be used:

Runtime.getRuntime().exec("ps -e");


In Java Coding,

String task;
try {
Process p = Runtime.getRuntime().exec("ps -e"); // Executing commands
BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream())); // To read the running tasks.


while ((task = input.readLine()) != null) {
System.out.println(task); //Lists the read tasks.
}
input.close();
} catch (Exception err) {
err.printStackTrace();
}
1084
like
0
dislike
0
mail
flag

You must LOGIN to add comments