the below code is to list the running exe files in the windows task manager. but i need only the running applications in windows task manager.
if aybody knows pls help me by sending code for this.
i am awaiting pls.

import java.util.*;

public class GetProcess {
public static List listRunningProcesses() {
List<String> processes = new ArrayList<String>();
try {
String line;
Process p = Runtime.getRuntime().exec("tasklist.exe /nh");
BufferedReader input = new BufferedReader
(new InputStreamReader(p.getInputStream()));
while ((line = input.readLine()) != null) {
if (!line.trim().equals("")) {
// keep only the process name
processes.add(line.substring(0, line.indexOf(" ")));

catch (Exception err) {
return processes;

public static void main(String[] args){
List<String> processes = listRunningProcesses();
String result = "";

// display the result
Iterator<String> it = processes.iterator();
int i = 0;
while (it.hasNext()) {
result += +",";
if (i==10) {
result += "\n";
i = 0;
msgBox("Running processes :\n " + result+"\n Total No of Processes: "+ processes.size());


public static void msgBox(String msg) {
null, msg, "WindowsUtils",

Why are you doing System type stuff using Java? It is not designed for it. If you want a command line command to get the "application" list that appears in TaskManager, then why are you asking in a Java forum? Ask in some Windows forum somewhere.

And don't cross-post. You have posted this same non-Java question (with this nominal Java code in the JSP forum as well, where it is even more out of place than it is here).

This article has been dead for over six months. Start a new discussion instead.