title: How do I redirect a javaw.exe console output to a log file?
body: <p>I am wanting to start my Java program from a batch file.  This is the script I want to use to start the app but the problem is that I am not able to get the console output to redirect to a log file.   Can anyone offer any hints without having to edit any code, and by using Java command line options or something?</p>
  
  <pre><code>@echo off
  set TASK=MyApp
  TITLE %TASK%
  start javaw.exe -cp .;Server.jar;Util.jar com.manage.Program %1 &gt; log.log 2&gt;&amp;1
  taskkill /T /FI "WINDOWTITLE eq %TASK%"
  </code></pre>
  
  <p>So, the above works, and actually kills the cmd window that spawns my Swing app, but it doesn't log anything to the log file, presumably because the "start" forked the process away from the "> log.log 2>&amp;1" arg?</p>
  
  <p>I could probably fix it by using start to call another batch file but I am hoping for a more elegant answer.</p>