Java 9 Improved Process API
Before Java 9, the Process API still lacked basic support for using native processes, such as obtaining the PID and owner of a process, the start time of the process, how much CPU time the process has used, how many native processes are running, etc.
Java 9 added an interface named ProcessHandle to the Process API to enhance the java.lang.Process class.
An instance of the ProcessHandle interface identifies a native process, allowing querying of process status and managing the process.
ProcessHandle's nested interface Info helps developers escape the dilemma of having to use native code to obtain the PID of a local process.
We cannot provide method implementations in interfaces. If we want to provide a combination of abstract and non-abstract methods (methods with implementations), then we have to use abstract classes.
The onExit() method declared in the ProcessHandle interface can be used to trigger certain actions when a process terminates.
Example
The output of the above example is:
Process ID : 5800 Command name : C:\Windows\System32\notepad.exe Command line : Not Present Start time: 2017-11-04T21:35:03.626 Arguments : Not Present User: administratorOther Extensions
Java 9 New Features