Java ProcessHandle get all processes
public class Main { public static void main(String[] args) { System.out.printf("All processes PIDs:%n"); ProcessHandle.allProcesses().map(ph -> ph.pid()).sorted().forEach(System.out::println); }/*from ww w .j av a 2 s. co m*/ }