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 ...