List all running processes in Java

Tasklist displays a list of applications and services with their Process ID (PID) for all tasks running on either a local or a remote computer.

void ListAllProcesses() {
	try {
		Process p = Runtime.getRuntime().exec("tasklist");
		BufferedReader reader = new BufferedReader(
				new InputStreamReader(p.getInputStream()));
		String line;
		while ((line = reader.readLine()) != null) {
			System.out.println(line);
		}
	} catch (Exception ex) {
		System.err.println(ex.getMessage());
	}
}
1 comment Categories: Java Tags: , , , ,
%d bloggers like this: