Find running apps in windows which can be seen in task manager under Apps Section. I want java code for getting that particular Apps list. i am able to get whole running background processes but i want running APPLICATION which shows under Apps tab in Task manager.
Asked
Active
Viewed 567 times
-2
-
2Have you tried anything? First google result for the query "find running apps using java" gives this: http://stackoverflow.com/questions/54686/how-to-get-a-list-of-current-open-windows-process-with-java – Pramod Karandikar Mar 02 '15 at 08:15
-
JNI/JNA intergration – MadProgrammer Mar 02 '15 at 08:27
-
i have seen that answer. It shows whole background process. I just need Application running which are under Apps in task manager. How could i filter it?? – Maulik Mar 02 '15 at 08:53
1 Answers
0
Try this
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");
Josh Crozier
- 219,308
- 53
- 366
- 287
Lafontein
- 242
- 1
- 6
-
I tried this before but it gives whole processes i just need RUNNING APPLICATION. – Maulik Mar 02 '15 at 09:26