title: Java : How to include a .properties file that is outside of jar into classpath?
body: <p>We would like to keep the .properties file out of the jar so that we can change the properties used in a module and we do not have to re-install the module.</p>
  
  <p>Before Java 8, we used to run a script and include the .properties file in the way below and it worked. But since when we updated to Java 8 , this way of including .properties file in classpath is not working, means java program fails not finding the .properties file.</p>
  
  <p><strong>My script to run the java project:</strong></p>
  
  <pre><code>/usr/java/latest/bin/java -d64 -Xms1G -Xmx16G -XX:MaxPermSize=128m -XX:-UseGCOverheadLimit -cp "/online/sand/lib/client-api-1.0.0.jar:/online/sand/oap_pub/lib/*:/online/sand/oap/oap_dw/run/client_api/application.properties" team.online.client.api.MasterProcessor  | tee -a client_api.log
  </code></pre>
  
  <p>We are using Sping context to pick up the properties file this way:</p>
  
  <pre><code>&lt;util:properties id="app_props"
                   location="classpath*:/application.properties" /&gt;
  </code></pre>
  
  <p>Then a property in that appilcation.properties files is being used ( in many different files) this way:</p>
  
  <pre><code>@Value( "#{app_props[\"SERVICE_PATH_GET_METADATA\"]?:''}" )
  private String metadataServicePath;
  </code></pre>
  
  <p>Looking for a way to keep the.properties file out of the jar and in classpath so that Spring context finds that file.</p>
  
  <p><strong>Is their any other way than using ? We need to keep the properties file excluded from jar</strong></p>
  
  <pre><code>class.getClassLoader( ).getResourceAsStream( "application.properties" );
  </code></pre>
  
  <p>Thanks in advance. </p>