{"id":374,"date":"2019-02-21T07:43:06","date_gmt":"2019-02-21T07:43:06","guid":{"rendered":"https:\/\/jan.schnasse.org\/blog\/?p=374"},"modified":"2026-09-28T11:39:16","modified_gmt":"2026-09-28T09:39:16","slug":"java-properties-part-2","status":"publish","type":"post","link":"https:\/\/jan.schnasse.org\/blog\/2019\/02\/21\/java-properties-part-2\/","title":{"rendered":"Java Properties: Part 2"},"content":{"rendered":"<p>Load a properties file from current directory.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"java\">Properties properties = new Properties();\nproperties.load(new FileReader(new File(\".\").getCanonicalPath() + File.separator + \"java.properties\"));\n<\/pre>\n<p>Write a start script<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\">#! \/bin\/bash\nscriptdir=\"$( cd \"$( dirname \"${BASH_SOURCE[0]}\" )\" &amp;&amp; pwd )\"\ncd $scriptdir\njava -jar MyExecutable.jar\ncd -<\/pre>\n<p>Now you can start your configurable java program from any location, e.g. by linking the startscript to \/usr\/bin\/ .<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Load a properties file from current directory. Properties properties = new Properties(); properties.load(new FileReader(new File(&#8222;.&#8220;).getCanonicalPath() + File.separator + &#8222;java.properties&#8220;)); Write a start script #! \/bin\/bash scriptdir=&#8220;$( cd &#8222;$( dirname &#8222;${BASH_SOURCE[0]}&#8220; )&#8220; &amp;&amp; pwd )&#8220; cd $scriptdir java -jar MyExecutable.jar cd &#8211; Now you can start your configurable java program from any location, e.g. by linking [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[],"class_list":["post-374","post","type-post","status-publish","format-standard","hentry","category-java"],"_links":{"self":[{"href":"https:\/\/jan.schnasse.org\/blog\/wp-json\/wp\/v2\/posts\/374","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jan.schnasse.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jan.schnasse.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jan.schnasse.org\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jan.schnasse.org\/blog\/wp-json\/wp\/v2\/comments?post=374"}],"version-history":[{"count":1,"href":"https:\/\/jan.schnasse.org\/blog\/wp-json\/wp\/v2\/posts\/374\/revisions"}],"predecessor-version":[{"id":4385,"href":"https:\/\/jan.schnasse.org\/blog\/wp-json\/wp\/v2\/posts\/374\/revisions\/4385"}],"wp:attachment":[{"href":"https:\/\/jan.schnasse.org\/blog\/wp-json\/wp\/v2\/media?parent=374"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jan.schnasse.org\/blog\/wp-json\/wp\/v2\/categories?post=374"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jan.schnasse.org\/blog\/wp-json\/wp\/v2\/tags?post=374"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}