Launch JVM process from a Java application use Runtime.exec?

Berlin Brown picture Berlin Brown · Jan 26, 2009 · Viewed 32.9k times · Source

I want to be able to launch a Java server process from an existing java application and monitor the stdoutput and stderror and redirect that output to a file. Is the best approach to use 'Runtime.exec' and treat the app like any other OS process or is there something more suited for new JVMs.

This is on Java 1.5

Answer

Fabian Steeg picture Fabian Steeg · Jan 26, 2009

Instead of Runtime, you should probably use ProcessBuilder, though I don't know if something else is even more appropriate in your case (running a Java process in particular).