To find the number of processes running in a machine and print those in table format
import java.io.BufferedReader; import java.io.InputStreamReader; public class NoofProcess { public static void main(String[] args) { try { // Process p = Runtime.getRuntime().exec("cmd /c tasklist /v"); Process p = Runtime.getRuntime().exec("tasklist.exe /nh /v"); BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getInputStream())); String input, output = ""; while ((input = stdInput.readLine()) != null) { output += input; System.out.println(input); } stdInput.close(); } catch (Exception k) { k.printStackTrace(); } } }