Process API Updates

Java 9 has come with the changes which will let you fetch the pid of a process. Following code shows how to get a pid with Java 9

ProcessBuilder pb = new ProcessBuilder("notepad");
		        Process p = pb.start();

		 System.out.println("Pid of Process : " + p.getPid());

getPid function internally call getProcessId0 with process’s handle to retrieve pid. getProcessId0 is a native method.

Apart from process id, other targeted changes are :

  • Ability to get/set the process name
  • Ability to enumerate Java virtual machines and processes to get pid, name, state, and perhaps resource usage
  • Api to do “End Process Tree”. EndProcessTree

Thanks Robin for the update, JDK 9 docs are now available here http://download.java.net/jdk9/docs/api/java/lang/ProcessBuilder.html

Tagged on:             

2 thoughts on “JEP 102- Process API Updates

Leave a Reply

Your email address will not be published.


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>