How to get a list of current open windows/process with Java?

Question :

How to get a list of current open windows/process with Java?,

Answer :

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 process open, like in Windows Taskmanager, but using a multi-platform approach – using only Java if it’s possible.

,

This is another approach to parse the the process list from the command “ps -e“:

try {      String line;      Process p = Runtime.getRuntime().exec("ps -e");      BufferedReader input =              new BufferedReader(new InputStreamReader(p.getInputStream()));      while ((line = input.readLine()) != null) {          System.out.println(line); //<-- Parse data here.      }      input.close();  } catch (Exception err) {      err.printStackTrace();  }  

If you are using Windows, then you should change the line: “Process p = Runtime.getRun…” etc… (3rd line), for one that looks like this:

Process p = Runtime.getRuntime().exec      (System.getenv("windir") +"\system32\"+"tasklist.exe");  

Hope the info helps!

Read More  Where are people getting that rotating loading image?

That's the answer How to get a list of current open windows/process with Java?, Hope this helps those looking for an answer. Then we suggest to do a search for the next question and find the answer only on our site.

Disclaimer :

The answers provided above are only to be used to guide the learning process. The questions above are open-ended questions, meaning that many answers are not fixed as above. I hope this article can be useful, Thank you