{"id":4678,"date":"2014-03-30T14:34:37","date_gmt":"2014-03-30T14:34:37","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/how-do-i-run-a-batch-file-from-my-java-application-collection-of-common-programming-errors\/"},"modified":"2014-03-30T14:34:37","modified_gmt":"2014-03-30T14:34:37","slug":"how-do-i-run-a-batch-file-from-my-java-application-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/how-do-i-run-a-batch-file-from-my-java-application-collection-of-common-programming-errors\/","title":{"rendered":"How do I run a batch file from my Java Application?-Collection of common programming errors"},"content":{"rendered":"<p>The executable used to run batch scripts is <code>cmd.exe<\/code> which uses the <code>\/c<\/code> flag to specify the name of the batch file to run:<\/p>\n<pre><code>Runtime.getRuntime().exec(new String[]{\"cmd.exe\", \"\/c\", \"build.bat\"});\n<\/code><\/pre>\n<p>Theoretically you should also be able to run Scons in this manner, though I haven&#8217;t tested this:<\/p>\n<pre><code>Runtime.getRuntime().exec(new String[]{\"scons\", \"-Q\", \"implicit-deps-changed\", \"build\\file_load_type\", \"export\\file_load_type\"});\n<\/code><\/pre>\n<p>EDIT: Amara, you say that this isn&#8217;t working. The error you listed is the error you&#8217;d get when running Java from a Cygwin terminal on a Windows box; is this what you&#8217;re doing? The problem with that is that Windows and Cygwin have different paths, so the Windows version of Java won&#8217;t find the scons executable on your Cygwin path. I can explain further if this turns out to be your problem.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The executable used to run batch scripts is cmd.exe which uses the \/c flag to specify the name of the batch file to run: Runtime.getRuntime().exec(new String[]{&#8220;cmd.exe&#8221;, &#8220;\/c&#8221;, &#8220;build.bat&#8221;}); Theoretically you should also be able to run Scons in this manner, though I haven&#8217;t tested this: Runtime.getRuntime().exec(new String[]{&#8220;scons&#8221;, &#8220;-Q&#8221;, &#8220;implicit-deps-changed&#8221;, &#8220;build\\file_load_type&#8221;, &#8220;export\\file_load_type&#8221;}); EDIT: Amara, you say [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-4678","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4678","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=4678"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4678\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=4678"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=4678"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=4678"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}