title: Running a JAVA program as a scheduled task
body: <p>I am trying to run a simple JAVA program once per day on a Windows 7 machine.</p>
  
  <p>My code runs fine inside NetBeans. If I do a clean and build it suggests this:</p>
  
  <pre><code>C:\Program Files\Java\jdk1.7.0/bin/java -jar "C:\Users\User1\Documents\NetBeansProjects\Facebook\dist\Facebook.jar"
  </code></pre>
  
  <p>This does not work from the DOS prompt of course because of the space between program and files so I do this:</p>
  
  <pre><code>C:\Program Files\Java\jdk1.7.0/bin/java -jar "C:\Users\User1\Documents\NetBeansProjects\Facebook\dist\Facebook.jar" -jar "C:\Users\User1\Documents\NetBeansProjects\Facebook\dist\Facebook.jar"
  </code></pre>
  
  <p>This works from the DOS prompt.</p>
  
  <p>I now create a task in Windows Scheduler to run:</p>
  
  <pre><code>C:\Program Files\Java\jdk1.7.0/bin/java
  </code></pre>
  
  <p>with arguments:</p>
  
  <pre><code>-jar "C:\Users\User1\Documents\NetBeansProjects\Facebook\dist\Facebook.jar"
  </code></pre>
  
  <p>When I then run it, all I see is a DOS box flashing up for a second. I expect the code to take about 30 secs to run. The code should persist data to a database and no updates happen.</p>
  
  <p>The code also uses <code>java.util.logging</code> so I should see log entries and I don't.</p>
  
  <p>I strongly suspect that I am not running the JAVA command properly or that there's a bad classpath issue that it present when running via Scheduler that isn't there when running from the DOS prompt.</p>
  
  <p>Help would be appreciated. If you've seen this before and can sort it that would be great. If you can tell me how to get a meaningful error trace from Scheduler than that would also be really helpful.</p>
  
  <p>Thanks!</p>