{"id":5236,"date":"2018-09-03T21:43:01","date_gmt":"2018-09-04T04:43:01","guid":{"rendered":"https:\/\/www.coretechnologies.com\/blog\/?p=5236"},"modified":"2018-09-03T21:43:01","modified_gmt":"2018-09-04T04:43:01","slug":"run-java-exe-from-path","status":"publish","type":"post","link":"https:\/\/www.coretechnologies.com\/blog\/alwaysup\/run-java-exe-from-path\/","title":{"rendered":"Q &#038; A: How do I get AlwaysUp to run Java.exe in the PATH?"},"content":{"rendered":"<div align=\"center\"><img decoding=\"async\" src=\"https:\/\/cdn.coretechnologies.com\/blog\/images\/qa-java.png\" title=\"Q &#038; A - Java\" alt=\"Q &#038; A - Java\" border=\"0\" ><\/div>\n<div class=\"blog-qa-question-box\">\n<img decoding=\"async\" src=\"\/images\/quotes-transparent-21x21.png\">&nbsp;&nbsp;I run a Java program <a href=\"http:\/\/www.echolink.org\/proxy.htm\" target=\"_blank\" rel=\"noopener noreferrer\">EchoLink Proxy<\/a> as part of Ham Radio networking. A routine update replaced the Java folder with its new version number thus my AlwaysUp Application field to run the program needed manual edit from:<\/p>\n<blockquote><p>C:\\Program Files (x86)\\Java\\jre1.8.0_171\\bin\\java.exe<\/p><\/blockquote>\n<p>to<\/p>\n<blockquote><p>C:\\Program Files (x86)\\Java\\jre1.8.0_181\\bin\\java.exe<\/p><\/blockquote>\n<p>I tried simply providing &#8220;Java.exe&#8221; (which works from a CMD prompt) but AlwaysUp requires the full-path. How can I get AlwaysUp to run the Java.exe in my PATH environment variable?<\/p>\n<p align=\"right\">&#8212; Anonymous<\/p>\n<\/div>\n<p>Hi. AlwaysUp expects a full path, so I see the problem!<\/p>\n<p>We recommend adding a &#8220;layer of indirection&#8221; to solve the problem. Please:<\/p>\n<ol>\n<li>\n<p>\nCreate a new Windows batch file that runs your full java command line. However, instead of specifying the full path to java, simply use <b>java.exe<\/b>.\n<\/p>\n<p>\nWhen run, the batch file will use whatever <b>java.exe<\/b> is in your Windows account&#8217;s PATH variable.\n<\/p>\n<p>\nHere is what our simple batch file (saved to &#8220;C:\\Tools\\start-java-app.bat&#8221;) looks like:\n<\/p>\n<div align=\"center\"><a href=\"https:\/\/cdn.coretechnologies.com\/blog\/images\/start-java-batch-file.png\" class=\"zoomPopup\" title=\"Start Java Batch File\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"image-padding\" src=\"https:\/\/cdn.coretechnologies.com\/blog\/images\/start-java-batch-file.png\" title=\"Start Java Batch File (click to enlarge)\" alt=\"Start Java Batch File\" border=\"0\" width=\"520\" \/><\/a><\/div>\n<p>\nPlease open a command prompt, run your batch file and confirm that it launches your program (EchoLink Proxy) as you expect.\n<\/p>\n<\/li>\n<li>\n<p>\nUpdate your AlwaysUp entry to run the new batch file. Specify the full path to the batch file in the <b>Application<\/b> field on the <b>General<\/b> tab:\n<\/p>\n<div align=\"center\"><a href=\"https:\/\/cdn.coretechnologies.com\/blog\/images\/run-batch-file-to-start-java-service.png\" class=\"zoomPopup\" title=\"Run the Batch File in AlwaysUp\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"image-padding\" src=\"https:\/\/cdn.coretechnologies.com\/blog\/images\/run-batch-file-to-start-java-service.png\" title=\"Run the Batch File in AlwaysUp (click to enlarge)\" alt=\"Run the Batch File in AlwaysUp\" border=\"0\" ><\/a><\/div>\n<p>\nBe sure to clear the <b>Arguments<\/b> field if it contains the parameters for the Java command line! Those should already appear in the batch file.\n<\/p>\n<\/li>\n<li>\n<p>\nAnd on the AlwaysUp <b>Logon<\/b> tab, specify the Windows account you are logged in to right now. Java must be launched in this account so that it finds the correct PATH environment value.\n<\/p>\n<div align=\"center\"><a href=\"https:\/\/cdn.coretechnologies.com\/blog\/images\/set-logon-account-for-java-service.png\" class=\"zoomPopup\" title=\"Set the account for running Java as a service\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"image-padding\" src=\"https:\/\/cdn.coretechnologies.com\/blog\/images\/set-logon-account-for-java-service.png\" title=\"Set the account for running Java as a service (click to enlarge)\" alt=\"Set the account for running Java as a service\" border=\"0\" ><\/a><\/div>\n<\/li>\n<li>\n<p>\nFinally, update the new batch file to add a 5 second delay at the end. We recommend using the <a href=\"https:\/\/ss64.com\/nt\/timeout.html\" target=\"_blank\" rel=\"noopener noreferrer\">Windows TIMEOUT command<\/a>, but there are <a href=\"http:\/\/www.robvanderwoude.com\/wait.php\" target=\"_blank\" rel=\"noopener noreferrer\">several alternatives<\/a>:\n<\/p>\n<blockquote><p><b>timeout \/t 5<\/b><\/p><\/blockquote>\n<p>\nWithout this adjustment, the batch file may exit very quickly and fool AlwaysUp into thinking that the batch file failed to start properly.\n<\/p>\n<div align=\"center\"><a href=\"https:\/\/cdn.coretechnologies.com\/blog\/images\/java-batch-file-with-timeout.png\" class=\"zoomPopup\" title=\"Add a Timeout to the Batch File\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"image-padding\" src=\"https:\/\/cdn.coretechnologies.com\/blog\/images\/java-batch-file-with-timeout.png\" title=\"Add a Timeout to the Batch File (click to enlarge)\" alt=\"Add a Timeout to the Batch File\" border=\"0\" width=\"520\" \/><\/a><\/div>\n<\/li>\n<li>\n<p>\nSave your batch file &mdash; and your settings in AlwaysUp.\n<\/p>\n<\/li>\n<\/ol>\n<p style=\"padding-top:20px;\">\nNow, when you start your modified entry from AlwaysUp, the following will happen:\n<\/p>\n<ol>\n<li>\n<p>AlwaysUp will start the batch file<\/p>\n<\/li>\n<li>\n<p>The batch file will launch Java from the PATH, as you have configured<\/p>\n<\/li>\n<li>\n<p>The batch file will &#8220;sleep&#8221; for 5 seconds<\/p>\n<\/li>\n<li>\n<p>The batch file will exit<\/p>\n<\/li>\n<li>\n<p>AlwaysUp will notice that the batch file has exited and &#8220;attach&#8221; to the Java.exe child process<\/p>\n<\/li>\n<li>\n<p>AlwaysUp will continue to monitor Java.exe and restart it (via the batch file) if it ever crashes\/fails\/exits.<\/p>\n<\/li>\n<\/ol>\n<p>\nAny monitoring, reporting and alerts you have configured should continue to work as they did before.\n<\/p>\n<p style=\"padding-top:20px;\">\nPlease <a href=\"\/support\/\">let us know<\/a> if you run into any trouble implementing this approach!<\/p>\n<!-- relpost-thumb-wrapper --><div class=\"relpost-thumb-wrapper\"><!-- filter-class --><div class=\"relpost-thumb-container\"><style>.relpost-block-single-image, .relpost-post-image { margin-bottom: 10px; }<\/style><h3>You may also like...<\/h3><div style=\"clear: both\"><\/div><div style=\"clear: both\"><\/div><!-- relpost-block-container --><div class=\"relpost-block-container relpost-block-column-layout\" style=\"--relposth-columns: 3;--relposth-columns_t: 2; --relposth-columns_m: 2\"><a href=\"https:\/\/www.coretechnologies.com\/blog\/alwaysup\/multiple-alpha-servers\/\"class=\"relpost-block-single\" ><div class=\"relpost-custom-block-single\"><img decoding=\"async\" loading=\"lazy\" class=\"relpost-block-single-image\" alt=\"Q &amp; A: How do I Prevent Multiple Alpha Application Servers from Running?\"  src=\"https:\/\/www.coretechnologies.com\/blog\/wp-content\/uploads\/qa-150x150.png\" style=\"aspect-ratio:1\/1\" style=\"aspect-ratio:1\/1\"><\/img><div class=\"relpost-block-single-text\"  style=\"height: 75px;font-family: Arial;  font-size: 12px;  color: #333333;\"><h2 class=\"relpost_card_title\">Q &amp; A: How do I Prevent Multiple Alpha Application Servers from Running?<\/h2><\/div><\/div><\/a><a href=\"https:\/\/www.coretechnologies.com\/blog\/sales\/create-a-quote\/\"class=\"relpost-block-single\" ><div class=\"relpost-custom-block-single\"><img decoding=\"async\" loading=\"lazy\" class=\"relpost-block-single-image\" alt=\"Need an Official Sales Quote? Create a PDF in 1-2 Minutes\"  src=\"https:\/\/www.coretechnologies.com\/blog\/wp-content\/uploads\/price-quote-150x150.png\" style=\"aspect-ratio:1\/1\" style=\"aspect-ratio:1\/1\"><\/img><div class=\"relpost-block-single-text\"  style=\"height: 75px;font-family: Arial;  font-size: 12px;  color: #333333;\"><h2 class=\"relpost_card_title\">Need an Official Sales Quote? Create a PDF in 1-2 Minutes<\/h2><\/div><\/div><\/a><a href=\"https:\/\/www.coretechnologies.com\/blog\/software\/dropbox-selective-sync-popup\/\"class=\"relpost-block-single\" ><div class=\"relpost-custom-block-single\"><img decoding=\"async\" loading=\"lazy\" class=\"relpost-block-single-image\" alt=\"Watch out for Dropbox Prompts when Running as a Service!\"  src=\"https:\/\/www.coretechnologies.com\/blog\/wp-content\/uploads\/hand-stop-150x150.png\" style=\"aspect-ratio:1\/1\" style=\"aspect-ratio:1\/1\"><\/img><div class=\"relpost-block-single-text\"  style=\"height: 75px;font-family: Arial;  font-size: 12px;  color: #333333;\"><h2 class=\"relpost_card_title\">Watch out for Dropbox Prompts when Running as a Service!<\/h2><\/div><\/div><\/a><\/div><!-- close relpost-block-container --><div style=\"clear: both\"><\/div><\/div><!-- close filter class --><\/div><!-- close relpost-thumb-wrapper -->","protected":false},"excerpt":{"rendered":"<p>&nbsp;&nbsp;I run a Java program EchoLink Proxy as part of Ham Radio networking. A routine update replaced the Java folder with its new version number thus my AlwaysUp Application field to run the program needed manual edit from: C:\\Program Files &hellip; <a href=\"https:\/\/www.coretechnologies.com\/blog\/alwaysup\/run-java-exe-from-path\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":3560,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[26,44,72,94,113,127],"class_list":["post-5236","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-alwaysup","tag-alwaysup-tag","tag-batch-file","tag-echolink-proxy","tag-java","tag-path-environment-variable","tag-qa"],"_links":{"self":[{"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/posts\/5236","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/comments?post=5236"}],"version-history":[{"count":0,"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/posts\/5236\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/media\/3560"}],"wp:attachment":[{"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/media?parent=5236"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/categories?post=5236"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/tags?post=5236"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}