O'Reilly logo

Java 9 Cookbook by Nick Samoylov, Mohamed Sanaulla

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Enumerating live processes in the system

In Windows, you open up the Windows Task Manger to view the processes currently active, and in Linux, you use the ps command with its varied options to view the processes along with other details, such as user, time spent, command, and so on.

 

In Java 9, a new API has been added, called ProcessHandle, which deals with controlling and getting information about the processes. One of the methods of the API is allProcesses(), which returns a snapshot of all the processes visible to the current process. In this recipe, we will look at how the method works and what information we can extract from the API.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required