{"id":4869,"date":"2014-03-30T16:11:12","date_gmt":"2014-03-30T16:11:12","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/runtime-getruntime-exec-returns-empty-string-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:42:27","modified_gmt":"2022-08-30T15:42:27","slug":"runtime-getruntime-exec-returns-empty-string-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/runtime-getruntime-exec-returns-empty-string-collection-of-common-programming-errors\/","title":{"rendered":"Runtime.getRuntime().exec returns empty string-Collection of common programming errors"},"content":{"rendered":"<p>This is the code I use:<\/p>\n<pre><code>    Runtime runtime = Runtime.getRuntime();\n    Process process = runtime.exec(\"cmd \/C cd C:\/Users\/ASUS\/Desktop\/semantics\/semantics\/bin\");\n    process = runtime.exec(\"java test \\\"abc\\\" \\\"def\\\"\");\n    InputStream is = process.getInputStream();\n    InputStreamReader isr = new InputStreamReader(is);\n    BufferedReader br = new BufferedReader(isr);\n    String line = \"\", tmp;\n\n    while ((tmp = br.readLine()) != null) {\n        line += tmp;\n    }\n\n    System.out.println(line);\n<\/code><\/pre>\n<p>I tried to use commands such as &#8220;cmd \/C dir&#8221; and i got a proper return value.<\/p>\n<p>And this is my test application :<\/p>\n<pre><code>import semantics.Compare;\npublic class USAGE {\npublic static void main(String[] args) {        \nString a = args[0];\nString b = args[1];\nCompare c = new Compare(a,b);\nSystem.out.println(c.getResult());\n}\n}\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>This is the code I use: Runtime runtime = Runtime.getRuntime(); Process process = runtime.exec(&#8220;cmd \/C cd C:\/Users\/ASUS\/Desktop\/semantics\/semantics\/bin&#8221;); process = runtime.exec(&#8220;java test \\&#8221;abc\\&#8221; \\&#8221;def\\&#8221;&#8221;); InputStream is = process.getInputStream(); InputStreamReader isr = new InputStreamReader(is); BufferedReader br = new BufferedReader(isr); String line = &#8220;&#8221;, tmp; while ((tmp = br.readLine()) != null) { line += tmp; } System.out.println(line); I [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,1],"tags":[],"class_list":["post-4869","post","type-post","status-publish","format-standard","hentry","category-semantic","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4869","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=4869"}],"version-history":[{"count":1,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4869\/revisions"}],"predecessor-version":[{"id":8781,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4869\/revisions\/8781"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=4869"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=4869"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=4869"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}