Ce diaporama a bien été signalé.
Nous utilisons votre profil LinkedIn et vos données d’activité pour vous proposer des publicités personnalisées et pertinentes. Vous pouvez changer vos préférences de publicités à tout moment.

Java9 - Part II

13 vues

Publié le

This knolx explains the concept of process API Updates in Java 9. It covers the following topics :
1. Process
2. Process Builder
3. Process Handler
4. Process Handler Info

Publié dans : Logiciels
  • Soyez le premier à commenter

  • Soyez le premier à aimer ceci

Java9 - Part II

  1. 1. Java 9 - Part II Jasmine Kaur Software Consultant (Knoldus)
  2. 2. Agenda: Process API Updates ● Process ● Process Builder ● Process Handler ● Process Handler Info
  3. 3. New features which came in Java 9● JPMS ( Java Platform Modular System) ● Jshell ● Jlink ● Http2/Client ● ... ● Process API Updates
  4. 4. Process API Updates ● Process id of current running process ● Create a new process (Example : open a notepad, compile a java program) ● Destroy already running process (Example : Close a notepad, stop a java program) ● Get complete information of a process ● Get child process information ● Get parent process information
  5. 5. What’s new in Java 9 Process API ? ● Process class : Several new methods were added like pid(), info() etc ● ProcessBuilder : Use to create our own operating system process ● ProcessHandle interface : Use to handle the processes like access current running process, access the parent/child of a particular process ● ProcessHandle.Info : Inner interface inside ProcessHandle interface. It is use to provide the complete information of a current running process. Note: All these classes and interfaces are present inside java.lang package, so we are not required to use any import statements.
  6. 6. How to get ProcessHandle Object 1. ProcessHandle handle = ProcessHandle.current(); 2. ProcessHandle handle = process.toHandle(); // where process is the Process object 3. Optional<ProcessHandle> handle = ProcessHandle.of(PID);
  7. 7. ProcessHandle.Info Info interface provides information snapshot about : 1. Single process 2. All processes
  8. 8. ProcessBuilder This class is used to make the operating system processes. ProcessBuilder processBuilder = new ProcessBuilder(String... command); Process process = processBuilder.start(); Note : The argument should be a valid command to invoke the process.
  9. 9. Creation and destroying a process ● Create and destroy process from java using ProcessBuilder. ● Destroy a project which is not created from java.
  10. 10. References ● https://www.youtube.com/watch?v=K8Jc_EaBVMI&list=PLd3UqWTnYXOlcXp3b EgxelRegCgnAvcNe ● https://docs.oracle.com/javase/9/ Java Part-I video : https://www.youtube.com/watch?v=gvmTZMPBJPo&feature=youtu.be
  11. 11. Thank You !

×