title: Typesafe config - Setting placeholder values from a program
body: <p>Is there any way for dynamically changing the fields of a <strong>Typesafe config</strong> file, using source code to populate placeholders?</p>
  
  <p>For example, assume the following simple configuration statement</p>
  
  <pre><code>{
    values {
      string1: ${name1}
      string2: ${name2}
      string3: ${name3}
      string4: ${name4}
    }
  }
  </code></pre>
  
  <p>As discussed in <a href="https://github.com/typesafehub/config/blob/master/HOCON.md" rel="nofollow noreferrer">HOCON</a> documentation and mentioned in an <a href="https://stackoverflow.com/questions/18520235/how-to-use-system-properties-to-substitute-placeholders-in-typesafe-config-file">earlier StackOverflow question</a>, one can use environmental variables and system properties to achieve this.</p>
  
  <p>Is it possible to also do the same thing directly from a program? For instance, in <code>Java</code>, having a class <code>Constants</code> like</p>
  
  <pre><code>public class Constants
  {
    public static final String name1 = "A";
    public static final String name2 = "B";
    public static final String name3 = "C";
    public static final String name4 = "D";
  }
  </code></pre>
  
  <p>and populating the configuration fields from that class?</p>
  
  <p><code>HOCON</code> allows integrating <code>Java</code> and executing code in the config file but apparently there is no way to set config placeholders from within the integrated <code>Java</code> code.</p>