Pick the right config file
<p>I have created two files in my <code>src/main/resources</code> folder</p>

<pre><code>application-dev.conf
</code></pre>

<p>which contains</p>

<pre><code>dev {
  oracle {
    host = "foo"
  }
}
</code></pre>

<p>and 
    application-qa.conf</p>

<p>which contains</p>

<pre><code>qa {
  oracle {
    host = "bar"
  }
}
</code></pre>

<p>I read this configuration with the following code</p>

<pre><code>val env = args.lift(0).getOrElse("dev")
val parsedConfig = ConfigFactory.parseFile(new File(s"src/main/resources/application-${env}.conf"))
val conf = ConfigFactory.load(parsedConfig)
val config = conf.getConfig(env)
println(config.getString("oracle.host"))
</code></pre>

<p>Everything works great at development time and I am able to read the right configuration file based on the environment specified. If I don't specify anything then development is chosen.</p>

<p>However now when I package my jar file as an assembly using <code>sbt assembly</code> and now try to run my application from the command line <code>java -jar ./target/MyApplication.jar</code></p>

<p>I get an error</p>

<pre><code>Exception in thread "main" com.typesafe.config.ConfigException$Missing: No configuration setting found for key 'dev'
    at com.typesafe.config.impl.SimpleConfig.findKeyOrNull(SimpleConfig.java:152)
    at com.typesafe.config.impl.SimpleConfig.findOrNull(SimpleConfig.java:170)
    at com.typesafe.config.impl.SimpleConfig.find(SimpleConfig.java:184)
    at com.typesafe.config.impl.SimpleConfig.find(SimpleConfig.java:189)
</code></pre>

<p>My objective is that I should have multiple configuration files and I should be able to choose between them at dev time and also when the application is packaged as a jar.</p>

<p>Based on the suggestion below I modified my code to </p>

<pre><code>val env = args.lift(0).getOrElse("dev")
val parsedConfig = ConfigFactory.parseFile(new File(getClass.getResource(s"/application-${env}.conf").toURI))
val conf = ConfigFactory.load(parsedConfig)
val config = conf.getConfig(env)
println(config.getString("oracle.host"))
</code></pre>

<p>works in dev, but when I try to run my assembly it throws an exception</p>

<pre><code>Exception in thread "main" java.lang.IllegalArgumentException: URI is not hierarchical
    at java.io.File.&lt;init&gt;(File.java:418)
</code></pre>