User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JSP section within the Web Development category of DaniWeb, a massive community of 427,191 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,239 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JSP advertiser: Lunarpages JSP Web Hosting

how to get the running applications in windows task manager using java

Join Date: Oct 2007
Posts: 79
Reputation: hidash_in has a little shameless behaviour in the past 
Rep Power: 0
Solved Threads: 0
hidash_in hidash_in is offline Offline
Junior Poster in Training

Help how to get the running applications in windows task manager using java

  #1  
Oct 16th, 2007
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.io.*;
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(" ")));
}

}
input.close();
}
catch (Exception err) {
err.printStackTrace();
}
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 += it.next() +",";
i++;
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) {
javax.swing.JOptionPane.showConfirmDialog((java.awt.Component)
null, msg, "WindowsUtils",
javax.swing.JOptionPane.DEFAULT_OPTION);
}
}
AddThis Social Bookmark Button
Reply With Quote  
All times are GMT -4. The time now is 10:09 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC