Accessing the application.conf properties from java class with Play! 2.0

Try Play.application().configuration().getString("your.key")

As noted in the comment (nico_ekito), please use play.Play and not play.api.Play. play.api.Play is for scala controllers (see comment by Marcus biesior Biesioroff)

Additionally, play uses https://github.com/typesafehub/config under the hood so it can also provide some insights.


Even if it seems simple, here is the scala way to get properties from configuration file :

Play 2.0 and 2.1 :

import play.api.Play.current
...
Play.application.configuration.getString("your.key")

Play 2.2 and +

import play.api.Play.current
...
current.configuration.getString("your.key")

Using Typesafe config

import com.typesafe.config.ConfigFactory
...
ConfigFactory.load().getString("your.key");