0% found this document useful (0 votes)
75 views

Listing Running Processes in Taskmanager Using Java Web Service

This document describes how to list running processes in Task Manager using a Java web service. It provides source code to create a TaskManager web service that executes the tasklist.exe command to get a list of running processes. The output is read line by line and appended to a StringBuilder which is returned by the web service method.

Uploaded by

Study Iit
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
75 views

Listing Running Processes in Taskmanager Using Java Web Service

This document describes how to list running processes in Task Manager using a Java web service. It provides source code to create a TaskManager web service that executes the tasklist.exe command to get a list of running processes. The output is read line by line and appended to a StringBuilder which is returned by the web service method.

Uploaded by

Study Iit
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

| SOA Lab

22 December 2015 | 5:24:58 PM

5. LISTING RUNNING PROCESSES IN TASKMANAGER USING JAVA WEB


SERVICE
1. SOURCE CODE
import javax.jws.*;
import java.io.*;
@WebService(serviceName = "TaskManager")
public class TaskManager {
// list the currently running processes in Task Manager
@WebMethod(operationName = "showTaskManager")
public String showTaskManager()throws Exception {
// create the Runtime class by using static method getRuntime()
Runtime rt=Runtime.getRuntime();
// start the Task Manager
Process p=rt.exec("tasklist.exe");
InputStreamReader ir=new InputStreamReader(p.getInputStream());
BufferedReader br=new BufferedReader(ir);
String line;
StringBuilder sb=new StringBuilder();
while((line=br.readLine())!=null)
{
// append the process list to StringBuffer
sb.append(line);
System.out.println(line);
1

| SOA Lab

22 December 2015 | 5:24:58 PM

}
// display all the processes to web service
return sb.toString();
}
}

| SOA Lab

22 December 2015 | 5:24:58 PM

2. OUTPUT

| SOA Lab

22 December 2015 | 5:24:58 PM

2.1 DISPLAYING ALL ACTIVE PROCESSES IN TASK MANAGER

You might also like