Skip to content

Standalone Process

Michael Wieland edited this page Mar 12, 2018 · 3 revisions
  • Java9 Feature
  • Each JVM takes up one process.
  • You can start other processes with other JVM instances; these exist completely separate in memory, and generally are unrelated from each other.
  • Process and Processhandle

Communication

  • Socket
  • Write Files
  • RMI
  • Streams (using ProcessBuilder)

Variante 1

String[] startOptions = new String[] {"java", "-jar", "adv-root-1.0.jar"};
Process ps = Runtime.getRuntime().exec(startOptions);
ps.isAlive();

// ps.waitFor();

Variante 2

String[] startOptions = new String[] {"java", "-jar", "adv-root-1.0.jar"};
Process ps= new ProcessBuilder().command(startOptions).start();
ps.isAlive();

// ps.waitFor();

Process Information

ProcessHandle handle = ProcessHandle.current();
handle.pid();
handle.children().count();
Clone this wiki locally