Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Get all the current process and print out id of each
package com.knoldus;
import java.util.stream.Stream;
public class CurrentAllProcess {
public static void main(String[] args) throws Exception {
final Stream<ProcessHandle> currentProcesses = ProcessHandle.allProcesses();
currentProcesses.filter(ProcessHandle::isAlive).forEach(processHandle ->
System.out.println(processHandle.pid()));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment