{"id":5088,"date":"2014-03-30T18:44:17","date_gmt":"2014-03-30T18:44:17","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/java-runtime-exec-only-work-thru-console-collection-of-common-programming-errors\/"},"modified":"2014-03-30T18:44:17","modified_gmt":"2014-03-30T18:44:17","slug":"java-runtime-exec-only-work-thru-console-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/java-runtime-exec-only-work-thru-console-collection-of-common-programming-errors\/","title":{"rendered":"Java: Runtime.exec() only work thru console-Collection of common programming errors"},"content":{"rendered":"<p>A few tips:<\/p>\n<p>Just because you couldn&#8217;t get it to work differently using ProcessBuilder doesn&#8217;t mean that you should give up and use Runtime.exec(). Runtime.exec() is somewhere between really difficult and impossible to use for anything non-trival. So use ProcessBuilder &#8211; you&#8217;ll be happy you did.<\/p>\n<p>Use the ProcessBuilder constructor that takes a list, not the one that takes a String. The one that takes a string has exactly the same problems as Runtime.exec()<\/p>\n<p>If possible, use a batch file for Windows, or a shell script for Linux, that does as much of the work for you as possible (setting paths, etc.). Once you&#8217;ve debugged that at the command-line, you&#8217;ll have a much easier time using it with ProcessBuilder.<\/p>\n<p>Invoke your environment&#8217;s shell (e.g. cmd \/e or \/bin\/bash, or what-have-you, and have the shell execute the batch file.<\/p>\n<p>Don&#8217;t forget to read the output streams from the spawned process. If you don&#8217;t, the child process will very likely lock up.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A few tips: Just because you couldn&#8217;t get it to work differently using ProcessBuilder doesn&#8217;t mean that you should give up and use Runtime.exec(). Runtime.exec() is somewhere between really difficult and impossible to use for anything non-trival. So use ProcessBuilder &#8211; you&#8217;ll be happy you did. Use the ProcessBuilder constructor that takes a list, not [&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-5088","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5088","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=5088"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5088\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=5088"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=5088"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=5088"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}