how to find list of running processes in java

when we have to stop a process dynamically we must know about which processes are currently running on the system,This java program will lists all the currently running processes on windows using the tasklist.exe it will list all the exe applications currently running on the system.


import java.util.ArrayList;
import java.util.List;

public class ListCurrentRunningProcesses {

	public static void main(String[] args) {

		List<String> currentprocessesList = new ArrayList<String>();
		try {
			String str;
			Process process = Runtime.getRuntime().exec("tasklist.exe /nh");
			BufferedReader bufferedReader = new BufferedReader(
					new InputStreamReader(process.getInputStream()));
			while ((str = bufferedReader.readLine()) != null) {
				if (!str.trim().equals("")) {
							.add(str.substring(0, str.indexOf(" ")));
			System.out.println("No. Of Processes Currently running : "
					+ currentprocessesList.size());
			System.out.println("Names of Running Processes :"
					+ currentprocessesList);
		} catch (Exception err) {


Leave a Reply

Your email address will not be published. Required fields are marked *