Runtime.getRunTime().exec not behaving like C language “system()” command

前端 未结 5 441
忘了有多久
忘了有多久 2021-01-13 17:14

In \"C\", I can run a long blocking process in the background (AND HAVE IT CONTINUE TO RUN) after the starting process has exited.

void main(void)
{
      sy         


        
5条回答
  •  执念已碎
    2021-01-13 17:39

    EDIT:

    Have your tried this?

    Runtime.getRuntime().exec("/bin/sh -c /usr/X11/bin/xterm &")
    

    This worked for me on MacOS.

    Previous answer (JDK 1.5, apologies for not reading the question correctly):

    To execute a process without waiting you can use the ProcessBuilder

    ProcessBuilder pb = new ProcessBuilder("/usr/X11/bin/xterm");
    pb.start();
    

提交回复
热议问题