•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the JSP section within the Web Development category of DaniWeb, a massive community of 363,451 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 3,330 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
Views: 3941 | Replies: 4 | Solved
![]() |
•
•
Join Date: Oct 2007
Posts: 77
Reputation:
Rep Power: 0
Solved Threads: 0
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);
}
}
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);
}
}
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.
Edit: And this is the JSP forum. What you have posted is not JSP, but rather Java (nominally).
Edit: And this is the JSP forum. What you have posted is not JSP, but rather Java (nominally).
Last edited by masijade : Oct 16th, 2007 at 7:03 am.
Java Programmer and Sun Systems Administrator
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
•
•
Join Date: Jan 2008
Posts: 1
Reputation:
Rep Power: 0
Solved Threads: 1
Add the /v flag (verbose) on tasklist to see the application names "tasklist.exe /nh /v"
•
•
•
•
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);
}
}
•
•
•
•
Originally Posted by Amitji
Why u repling so stupid ans..He wants to find current running applications using java in his application and u r repling go to wnodow prompt....If u hv some decent ans rep otherwisw no need 2 rep
Because, his question was not about how to use Runtime.exec. He, suppossedly, knew how to do that already. His question was about which command to use, and that has absolutely nothing to do with Java, and so did not belong on this forum. So the advice given (to ask on a Windows forum or do some searching on his own) was spot on. Whether you like that fact or not does not concern me.
It also had, still does not have, absolutely anything to do with JSP, even if he was asking about how to use Runtime.exec. So keep your opinions to yourself, or at least make your remarks relevant. Anything else is a simple, whining, rant.
Java Programmer and Sun Systems Administrator
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb JSP Marketplace
•
•
•
•
aero apple browser cd choose computer crack dell development download drm explorer fiji ie 7 install internet java leopard linux microsoft microsystems mobile news office open operating os phishing photo platform programming registry security server software source sun system torvalds tweaks ubuntu unix upgrade vista volume web windows windows update windows vista xp
- Windows Task Manager Help (Viruses, Spyware and other Nasties)
- Windows Task Manager (Windows NT / 2000 / XP / 2003)
- Windows Task Manager (Alt + Cntrl + Del) NO LONGER THERE?? (Windows NT / 2000 / XP / 2003)
- Can't load task manager - Worm Removed (Viruses, Spyware and other Nasties)
- question about windows task manager (Viruses, Spyware and other Nasties)
- I have two svchost exe's running in the windows task manager (Windows NT / 2000 / XP / 2003)
Other Threads in the JSP Forum
- Previous Thread: First Servlet
- Next Thread: jsp not loading in JBoss server



Linear Mode