I'm writing an app in java allowing me to run other applications. To do that, I've used an Process class object, but when I do, the app awaits the process to end before exiting itself. Is there a way to run external application in Java, but don't wait for it to finish?
public static void main(String[] args)
{
FastAppManager appManager = new FastAppManager();
appManager.startFastApp("notepad");
}
public void startFastApp(String name) throws IOException
{
Process process = new ProcessBuilder(name).start();
}
ProcessBuilder.start() does not wait for process to finish. You need to call Process.waitFor() to get that behaviour.
I did a small test with this program
public static void main(String[] args) throws IOException, InterruptedException {
new ProcessBuilder("notepad").start();
}
When run in netbeans it appear to be still running. When running from command line with java -jar it returns immediately.
So your program is probably not waiting to exit, but your IDE makes it seem so.