{"id":4604,"date":"2014-03-30T13:58:00","date_gmt":"2014-03-30T13:58:00","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/exit-after-initializing-batch-script-from-java-collection-of-common-programming-errors\/"},"modified":"2014-03-30T13:58:00","modified_gmt":"2014-03-30T13:58:00","slug":"exit-after-initializing-batch-script-from-java-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/exit-after-initializing-batch-script-from-java-collection-of-common-programming-errors\/","title":{"rendered":"Exit after initializing batch script from java-Collection of common programming errors"},"content":{"rendered":"<p>I want to initialize one batch script using java code. Once it is initialized I need to exit the java program and wants the batch script to continue executing. How can I achieve this. I used Runtime and Process to do this. But it is waiting for the batch script to finish before proceeding to the next. This is the sample program I tried out.<\/p>\n<pre><code>        try {\n            Runtime r = Runtime.getRuntime();\n            System.out.println(\"Executing process\");\n            Process p = r.exec(\"c:\\\\anoop\\\\ping.bat\");\n            System.out.println(\"Executed process\"); \n            p.waitFor();\n            System.out.println(\"Exiting with out :: \");\n        } catch (Exception e) {\/\/ Catch exception if any\n            System.err.println(\"Error: \" + e.getMessage());\n            e.printStackTrace();\n        }\n<\/code><\/pre>\n<p>If I use p.exitValue(), it is giving error java.lang.IllegalThreadStateException: process has not exited. In short, I just want to initialize a batch script and then exit from the java program.<\/p>\n<p>Thanks, Anoop<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I want to initialize one batch script using java code. Once it is initialized I need to exit the java program and wants the batch script to continue executing. How can I achieve this. I used Runtime and Process to do this. But it is waiting for the batch script to finish before proceeding to [&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-4604","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4604","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=4604"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4604\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=4604"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=4604"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=4604"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}