Does any one know how do I get the current open windows or process of a local machine using Java?
What I\'m trying to do is: list the current open task, windows or
String line;
Process process = Runtime.getRuntime().exec("ps -e");
process.getOutputStream().close();
BufferedReader input =
new BufferedReader(new InputStreamReader(process.getInputStream()));
while ((line = input.readLine()) != null) {
System.out.println(line); //<-- Parse data here.
}
input.close();
We have to use process.getOutputStream.close()
otherwise it will get locked in while loop.