12 factor app config and Java

12 factor apps are designed to run on platforms that orchestrate isolated UNIX processes. UNIX processes are configured via environment variables. While property files are a well-established Java convention, UNIX processes are a language-agnostic way to configure processes.

To support multiple configuration methods, a good best practice is to:

  • Read from process environment with System.getenv('CONFIG'), if null
  • Read from property file with properties.getProperty('CONFIG'), if null
  • Fall back to a default value

For more details, see Heroku's instructions on defining config vars for Java apps.