ement HTTP 2.0 and websockets.5. The process API just got a huge boostSo far there has been a limited ability for controlling and managing operating system processes with Java. For example, in order to do something as simple as get your process PID in earlier versions of Java, you would need to either access native code or use some sort of a magical workaround. Moreover, it would require a different implementation for each platform to guarantee you’re getting the right result.In Java 9, expect the code for retrieving Linux PIDs, that now looks like this:01public static void main(String[] args) throws Exception02{03 Process proc = Runtime.getRuntime().exec(new String[]{ “/bin/sh”, “-c”, “echo $PPID” });04 05 if (proc.waitFor() == 0)06 {07 InputStream in = proc.getInputStream();08 int available = in.available();09 byte[] outputBytes = new byte[available];10 11 in.read(outputBytes);12 String pid = new String(outputBytes);13 14 System.out.println(“Your pid is ” + pid);15 }16}To turn into something like this (that also supports all operating systems):System.out.println(“Your pid is ” + Process.getCurrentPid());The update will extend Java’s ability to to interact with the operating system: New direct methods to handle PIDs, process names and states, and ability to enumerate JVMs and processes and more.
Source: 5 Features in Java 9 that WILL Change How You Develop Software (and 2 That Won’t) | Java Code Geeks