You need to parse the output of the tasklist, something like this:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class AppList {
public static void main(String[] args) {
try {
Process p = Runtime.getRuntime().exec("tasklist.exe /FO LIST");
BufferedReader in
= new BufferedReader(new InputStreamReader(p.getInputStream()));
String str = in.readLine();
while (str!=null) {
if (str.startsWith("Image Name:")) {
String appName = str.substring(11).trim();
System.out.println(appName);
}
str = in.readLine();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}