
- Java Tutorial
- Java - Home
- Java - Overview
- Java - Environment Setup
- Java - Basic Syntax
- Java - Object & Classes
- Java - Constructors
- Java - Basic Datatypes
- Java - Variable Types
- Java - Modifier Types
- Java - Basic Operators
- Java - Loop Control
- Java - Decision Making
- Java - Numbers
- Java - Characters
- Java - Strings
- Java - Arrays
- Java - Date & Time
- Java - Regular Expressions
- Java - Methods
- Java - Files and I/O
- Java - Exceptions
- Java - Inner classes
- Java Object Oriented
- Java - Inheritance
- Java - Overriding
- Java - Polymorphism
- Java - Abstraction
- Java - Encapsulation
- Java - Interfaces
- Java - Packages
- Java Advanced
- Java - Data Structures
- Java - Collections
- Java - Generics
- Java - Serialization
- Java - Networking
- Java - Sending Email
- Java - Multithreading
- Java - Applet Basics
- Java - Documentation
- Java Useful Resources
- Java - Questions and Answers
- Java - Quick Guide
- Java - Useful Resources
- Java - Discussion
- Java - Examples
What are the new methods added to Process API in Java 9?
Java 9 improves Process class by adding new methods and also provides a new interface: ProcessHandle and ProcessHandle.Info to get all the details about the process and its information.
Below is the list of new methods added to Process in Java 9
- boolean supportsNormalTermination(): It can return true if the implementation of the destroy() is to normally terminate the process, else returns false.
- long pid(): It can return the native process ID of the process.
- ProcessHandle toHandle(): It can return a ProcessHandle for the Process.
- Stream children(): It can return a snapshot of the direct children of the process.
- Stream descendants(): It can return a snapshot of the descendants of the process.
- ProcessHandle.Info info(): It can return a snapshot of information about the process.
- CompletableFuture onExit(): It can return a CompletableFuture for the termination of the process.
Example
public class ProcessTest { public static void main(String args[]) { ProcessHandle processHandle = ProcessHandle.current(); ProcessHandle.Info processInfo = processHandle.info(); System.out.println(processHandle.pid()); System.out.println(processHandle.parent()); System.out.println(processInfo.arguments().isPresent()); System.out.println(processInfo.command().isPresent()); System.out.println(processInfo.command().get().contains("tutorialspoint")); System.out.println(processInfo.startInstant().isPresent()); } }
Output
4892 Optional[7788] false true false true
- Related Articles
- What are the new features added to Stream API in Java 9?
- What are new methods added to the String class in Java 9?
- What are the new methods added to an Optional class in Java 9?
- What are new methods have added to the Arrays class in Java 9?
- What are the improvements in Process API in Java 9?
- What are the core library changes in Process API in Java 9?
- How to get the parent process of the Process API in Java 9?
- How to terminate/destroy a process using Process API in Java 9?
- How to traverse a process tree of Process API in Java 9?
- What are the steps to execute Flow API in Java 9?
- How to get all children of a process using Process API in Java 9?
- What are the CompletableFuture API improvements in Java 9?\n
- How to retrieve all processes data of Process API in Java 9?
- Which factory methods have added for collections in Java 9?
- How can we implement methods of Stream API in Java 9?

Advertisements