
- 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 improvements in Process API in Java 9?
Java has improved Process API in Java 9 version that helps to manage and control operating system processes. In earlier versions, it's difficult to manage and control operating system processes by using Java. Now, new classes and interfaces have added in Java 9 to perform this task. The ProcessHandle interface identifies and provides control of native processes and also provides a method to check processes liveness and destroy the processes. The ProcessHandle.Info interface gives an Information snapshot of the process.
The Process API provides more information like:
- Process's native process ID
- Accumulated CPU time
- Parent process
- Method to destroy a process
- Process’s Descendants, etc
Example
public class ProcessTest { public static void main(String args[]) { ProcessHandle currentProcess = ProcessHandle.current(); System.out.println("PID: " + currentProcess.pid()); ProcessHandle.Info currentProcessInfo = currentProcess.info(); System.out.println("totalCpuDuration: " + currentProcessInfo.totalCpuDuration()); System.out.println("user: " + currentProcessInfo.user()); } }
Output
PID: 6004 totalCpuDuration: Optional[PT0.421875S] user: Optional[Tutorialspoint\User]
- Related Articles
- What are the CompletableFuture API improvements in Java 9?\n
- What are the core library changes in Process API in Java 9?
- What are the new methods added to Process API in Java 9?
- What are the improvements for @Deprecated annotation in Java 9?
- What are the improvements for try-with-resources in Java 9?\n
- 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 new features added to Stream API in Java 9?
- How to retrieve all processes data of Process API in Java 9?
- StackWalker API in Java 9?
- What is Platform Logging API in Java 9?
- How to get a snapshot of information about Process API in Java 9?

Advertisements