Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Selected Reading
How to get a snapshot of information about Process API in Java 9?
Java 9 has improved Process API by including new methods and introduced new interfaces ProcessHandle and ProcessHandle.Info to get all the details regarding the process and its information.
ProcessHandle interface can identify and provide control of native processes. Each individual process can be monitored for liveness, listed its children, get information about the process, or destroys it. ProcessHandle.Info interface gives information snapshots about a process.
Syntax
<strong>ProcessHandle.Info info()</strong>
Example
public class ProcessSnapShotTest {
public static void main(String[] args) {
<strong>ProcessHandle </strong>currentProcessHandleImpl = <strong>ProcessHandle.current()</strong>;
<strong>// Process snapshot of the current running process with ProcessHandle.Info:</strong>
<strong>ProcessHandle.Info</strong> processInfo = currentProcessHandleImpl.<strong>info()</strong>;
System.out.println("nProcess snapshot of the current running process:");
System.out.println("User : " + processInfo.<strong>user().</strong><strong>get()</strong>);
System.out.println("Start Time : " + processInfo.<strong>startInstant().get()</strong>);
}
}
Output
<strong>Process snapshot of the current running process: User : Tutorialspoint\User Start Time : 2020-05-01T05:44:41.458Z</strong>
Advertisements
