Use False for waitForEnd then it should be an asynchroneous launch - at least for me under Windows (should try at home on Linux ;-) ): <code>public static int runProcess(String commandLine, boolean waitForEnd, StringBuilder output) { int rc = 0; boolean b = true; boolean r = true; Process prc = null; BufferedReader comeIn = null; BufferedWriter goOut = null;
Date started = new Date(); try { prc = Runtime.getRuntime().exec(commandLine); } catch (IOException ex) { //Log error } if (waitForEnd) comeIn = new BufferedReader(new InputStreamReader (prc.getInputStream())); //We expect the OS default encoding here although recommended to specify format always. if (output != null && comeIn != null) { String s = ""; String ls = getLineSep(); do { try { s = comeIn.readLine(); if (s != null) { output.append(s); output.append(ls); } } catch (IOException ex) { //Log error b = false; break; } } while (s != null); try { if (comeIn != null) comeIn.close(); } catch (IOException ex) { //Log Error } } if (waitForEnd) { while (r) { try { rc = prc.exitValue(); r = false; } catch (IllegalThreadStateException ex) { //Process not finished yet //You can check here if a timeout is reached if you want - in "started" is the date and time when the process has been started. } } } if (!b) { //Log error } return rc; }</code> --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "The Java Posse" group. To post to this group, send email to javaposse@googlegroups.com To unsubscribe from this group, send email to javaposse+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/javaposse?hl=en -~----------~----~----~----~------~----~------~--~---