La version actuellement supportée est toujours la 1.1, datant de 1999.
La nouvelle API supportant la version 2 sera bien plus simple à utiliser (utilisatio du pattern Builder)
Mise à jour de l’API Process afin de simplifier la récupération et la gestion des processus systèmes :
// Get PIDs of own or started processes
out.println("Your pid is " + ProcessHandle.current().getPid());
Process p = Runtime.getRuntime().exec("sleep 1h");
ProcessHandle h = ProcessHandle.of(p.getPid()) // Optional
.orElseThrow(IllegalStateException::new);
// Do things on exiting process // CompletableFuture
h.onExit().thenRun( ()-> out.println("Sleeper exited") );
// Get info on process
out.printf("[%d] %s - %s\n", h.getPid(),
h.info().user().orElse("unknown"),
h.info().commandLine().orElse("none"));
// Kill a process
h.destroy();REPL = Read Eval Print Loop
Correspond au projet Kulla, maintenant connu comme JShell.
Merci Guava !
/* Comment sections would break ... */
List<Integer> listOfNumbers = List.of(1, 2, 3, 4, 5/*, null*/);
Set<Integer> setOfNumbers = Set.of(1, 2, 3, 4, 5/*, 1*/);
Map<String, String> mapOfString =
Map.of("key1", "value1", "key2", "value2");
Map<String, String> moreMapOfString =
Map.ofEntries(
Map.entry("key1", "value1"),
Map.entry("key2", "value2")/*,
Map.entry("key1", "value3")*/
);