package com.nisum.java9Features.ProcessAPI; public class ProcessID { public static void main(String[] args) throws Exception { ProcessHandle p = ProcessHandle.current(); long pid = p.pid(); System.out.println("The PID of current running JVM instance :" + pid); Thread.sleep(100000); } }