Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I found a workaround in this <a href="http://www.oracle.com/technetwork/server-storage/solaris10/subprocess-136439.html" rel="nofollow noreferrer">article</a>, basically the idea is that you create a process early on in the startup of your application that you communicate with (via input streams) and then that subprocess executes your commands for you. </p> <pre><code>//you would probably want to make this a singleton public class ProcessHelper { private OutputStreamWriter output; public ProcessHelper() { Runtime runtime = Runtime.getRuntime(); Process process = runtime.exec("java ProcessHelper"); output = new OutputStreamWriter(process.getOutputStream()); } public void exec(String command) { output.write(command, 0, command.length()); } } </code></pre> <p>then you would make a helper java program</p> <pre><code>public class ProcessHelper { public static void main(String[] args) { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); String command; while((command = in.readLine()) != null) { Runtime runtime = Runtime.getRuntime(); Process process = runtime.exec(command); } } } </code></pre> <p>what we've essentially done is make a little 'exec' server for your application. If you initialize your ProcessHelper class early on in your application it will successfully create this process then you simply pipe commands over to it, because the second process is much smaller it should always succeed. </p> <p>You could also make your protocol a little more in depth, such as returning exitcodes, notifying of errors and so on. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload