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

How it works...

To give more control to the native processes and get its information, a new interface called ProcessHandle has been added to the Java API. Using ProcessHandle, you can control the process execution as well as get some information about the process. The interface has another inner interface called ProcessHandle.Info. This interface provides APIs to get information about the process. 

There are multiple ways to get hold of the ProcessHandle object for a process. Some of the ways are as follows:

  • ProcessHandle.current(): This is used to get the ProcessHandle instance for the current Java process
  • Process.toHandle(): This is used to get ProcessHandle for a given Process object
  • ProcessHandle.of(pid): This is used to get ProcessHandle ...

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