Improvement in API for controlling and managing the OS processes in java 9




Contents of page >


1) Improvement in API’s for controlling and managing the OS processes in java 9
Improvement in API’s for controlling and managing the OS (operating system) processes.
Limitations of current API’s forces developers to turn to native code, i.e. developers has to depend more on platform specific code.


Currently Java SE provides only limited support for handling native OS processes.


Java SE 7 provides a basic API to setup the environment and start a process.
Since Java SE 7, the process streams can be redirected to >
  • files,
  • pipe or
  • can be inherited.
The process streams API can be used to >
  • Destroy the process and/or
  • Wait for the process to terminate.


2) Improvement in java.lang.Process class in java 9 >
The java.lang.Process class is enhanced in java 9 to provide >
  • Pid (Process id) of the process,
  • Process Information including following >
    • Arguments passed to process,
    • Command used,
    • start time of process,
    • accumulated cpu time of the process and the
    • user name for the process.


3) Improvement in java.lang.ProcessHandle class in java 9 >
The java.lang.ProcessHandle class returns the information about each process as provided by the OS (operating system) in java 9 including following >
  • Pid (Process id) of the process,
  • Process Information including following >
    • Arguments passed to process,
    • Command used,
    • start time of process


  • ProcessHandle also returns important information like >
    • process' parent,
    • direct children, and
    • descendants via a stream of ProcessHandles.


ProcessHandle can be used to following >
  • destroy processes and
  • monitor process liveness.


About ProcessHandle.onExit in java 9 >
when the process exits the asynchronous mechanisms of CompletableFuture can be used to schedule an action in java 9.


4) Why there is need of Improvement in API’s for controlling and managing the OS processes in java 9 ?
Many huge applications like enterprise applications have multiple JVM’s and processes. So, they need to have the ability to
  • get the process id (PID) of current jvm and also the pid of processes which were created with the the existing API.
  • Mention the name, pid of all the processes running on the system.
  • Deal with the sub processes process .
  • Also deal with the process tree.


Summary >
In this java tutorial we learned about Improvement in API for controlling and managing the OS processes in java 9.


Developers won’t need to depend on much native code(platform specific code)
The java.lang.Process class enhanced in java 9 to provide >
  • Pid (Process id) of the process and
  • Process Information
The java.lang.ProcessHandle class returns the information about each process

Having any doubt? or you liked the tutorial! Please comment in below section.
Please express your love by liking JavaMadeSoEasy.com (JMSE) on facebook, following on google+ or Twitter.

RELATED LINKS>

varHandle (variable handle) in java 9

JVM logging system in Java 9 - Levels, tags, output, rotation, decoration


Labels: Core Java Java 9
eEdit
Must read for you :