title: Capturing output from java
body: <p>I'm trying to capture output from a java app but I'm missing something.  I'm using the following batch file:</p>
  
  <pre><code>@echo off
  echo Start of batch
  java makeQRCode
  echo End of batch
  </code></pre>
  
  <p>If I run the batch file from a command prompt, I see the 3 lines I'm expecting.</p>
  
  <pre><code>Start of batch
  Here is your java output.
  End of batch
  </code></pre>
  
  <p>When I call the batch file using the following code, I only see the first and last lines but not the one in the middle.</p>
  
  <pre><code>try{
      Runtime rt = Runtime.getRuntime();
      log.debug("Calling rt.exec...");
      Process pr = rt.exec("c:\\adhoc\\java\\qrcode\\makeQRCode.bat");
  
      BufferedReader input = new BufferedReader(new InputStreamReader(pr.getInputStream()));
      String line=null;
      while((line=input.readLine()) != null) {
          out.print(line);
          log.debug(line);
      }
      input.close();
  
      int exitVal = pr.waitFor();
  }catch (Exception e){
      log.error("Error generating qr code: " + e.toString());
  }       
  </code></pre>
  
  <p>Here's my log output when the above code is run:</p>
  
  <pre><code>2013-05-23 17:16:32,957 DEBUG _getimage - Start of batch
  2013-05-23 17:16:33,126 DEBUG _getimage - End of batch
  </code></pre>
  
  <p>I think I'm missing something related to stdout but I've been playing with it for hours now and just can't get it right.</p>
  
  <p>Thanks</p>