title: Java Properties does not load when I call the program from another location
body: <p>I have a program in which the properties file is in the same path as the program I'd like to run.</p>
  
  <p>The properties file name is initialized at the start of the program with:</p>
  
  <pre><code>public static final String DEFAULT_PROPERTIES_FILE = "defaultProperties.properties"; 
  </code></pre>
  
  <p>The program runs perfectly when running it in the directory it itself is located in with:</p>
  
  <pre><code>java -jar program.jar
  </code></pre>
  
  <p>When running the program from another directory with:</p>
  
  <pre><code>java -jar path/program.jar
  </code></pre>
  
  <p>The program will not find the properties file and returns a:</p>
  
  <p><em>java.io.FileNotFoundException: defaultProperties.properties (No such file or directory)</em></p>
  
  <h2>FIXED</h2>
  
  <p>I came up with a solution. It is possible to call the path of the class and give the path to the configurations file. </p>
  
  <pre><code>StringBuilder stringBuilder = new StringBuilder( PolicyBoosterTool.class.getProtectionDomain().getCodeSource().getLocation().getPath() );
  String pathToFolderOfJarFile = stringBuilder.substring( 0, stringBuilder.lastIndexOf( "/" ) + 1);
  
  DEFAULT_PROPERTIES_FILE =  pathToFolderOfJarFile + "defaultProperties.properties";
  </code></pre>
  
  <p>Sadly I can't mark the case as solved for myself. Any improvements to this are always welcome. Thank you for your help everyone!</p>