Using Java to spawn a process and keep it running after parent quits
As the title suggests is it possible to execute another java app from within a java app and kee开发者_如何学Cp the children running after main application quits?
I guess you could do
Runtime.getRuntime().exec(command);
where command is a java command
Maybe make the sub-process a service?
If you want to quit the JVM together with the main application, then use Fortega's suggestion (it's probably the best way to do it)!
There's also another approach, if you don't want to create new processes: You could run everything in a separate Thread, also the "main application". This would not exit the Java Virtual Machine, and the threads would run until they're finished (except if you set them up as Daemon threads).
精彩评论