title: Java process never stops
body: <p>I am trying to execute a process from my Java application, when I execute this process from the console it works right, but when I do getRuntime().exec() it starts but never ends, no exceptions, no exit values.
  The process I am trying to execute is pdftops.exe, an app that converts PDF files to PostScript.
  When I try to convert small files (executing from Java) it works OK, the problem is converting larger PDFs which may take longer (from 20 to 60 seconds). I think the problem may be that the execution time is too long.
  Here is the piece of code that calls the program (the command line is simplified, the input.pdf and output.ps are placed in a folder inside my home directory, and pdftops.exe is placed in Desktop):</p>
  
  <pre><code>String comando = "pdftops.exe input.pdf output.ps";
  System.out.println("Executing "+comando);
  try {
      Process pr = Runtime.getRuntime().exec(comando);            
      pr.waitFor();      
      System.out.println("Finished");
  }
  catch (IOException ex){
      ex.printStackTrace();
  }
  catch(InterruptedException ex){
      ex.printStackTrace();
  }
  </code></pre>
  
  <p>EDIT: Reading the process' ErrorStream solves the problem:</p>
  
  <pre><code>try {
      System.out.println(comando);
      Process process = Runtime.getRuntime().exec(comando);            
  
      String line;
  
      InputStream stderr = process.getErrorStream ();
  
      BufferedReader reader = new BufferedReader (new InputStreamReader(stderr));
  
      line = reader.readLine();
      while (line != null &amp;&amp; ! line.trim().equals("--EOF--")) {
          System.out.println ("Stdout: " + line);
          line = reader.readLine();
      }
  }
  catch (IOException ex){
      ex.printStackTrace();
  }
  </code></pre>