title: How to run Windows command from Java
body: <p>I would like execute the following command with Java:</p>
  
  <blockquote>
    <p>"C:\Program Files\MySQL\MySQL Server 5.5\bin\"mysqldump -u root
    --password=xxxx --routines database > C:\Users\john\Desktop\backup.sql</p>
  </blockquote>
  
  <p>The command works perfectly when I use the Windows cmd.exe but not with my Java application.</p>
  
  <pre><code>cmd = "\"C:\\Program Files\\MySQL\\MySQL Server 5.5\\bin\\\"mysqldump
  -u root --password=xxxx --routines database &gt; C:\\Users\\john\\Desktop\\backup.sql
  Runtime runtime = Runtime.getRuntime(); 
  process = runtime.exec(cmd);
  </code></pre>
  
  <p>I got the following error:</p>
  
  <blockquote>
    <p>"C:\Program Files\MySQL\MySQL Server 5.5\bin\"mysqldump -u root
    --password=xxxx --routines database > C:\Users\john\Desktop\backup.sql java.io.IOException: Cannot run program ""C:\Program": CreateProcess
    error=5, Access is denied</p>
  </blockquote>
  
  <p>Do you have any idea?</p>
  
  <p>Thank you.</p>