How can I unblock from a Java started process?

前端 未结 8 1067
旧巷少年郎
旧巷少年郎 2021-01-29 01:27

When executing some command(let\'s say \'x\') from cmd line, I get the following message: \"....Press any key to continue . . .\". So it waits for user input to unblock.

8条回答
  •  失恋的感觉
    2021-01-29 02:03

    So this is my workaround to this problem, inspired from Alnitak's suggestion: Run the command like this:

    Process p = Runtime.getRuntime().exec(cmd + " < c:\\someTextFile.txt", null, cmdDir);
    ...
    int errCode = p.waitFor();
    ...
    

    the 'someTextFile.txt' can be programatically created into the temporary dir then deleted.

提交回复
热议问题