How do I access a resource file relative to a Play application path (even when packaged into a distribution zip)?
This is the same problem as this, but in Play 2, which has no VirtualFile class in its api.
Thanks.
How do I access a resource file relative to a Play application path (even when packaged into a distribution zip)?
This is the same problem as this, but in Play 2, which has no VirtualFile class in its api.
Thanks.
Check out
play.api.Play.getFile()
andplay.api.Play.getExistingFile()
, which get files from the file system relative to the application directory.A similar technique that works for me is simply to add a resource directory (or jar) to the classpath in the play start script. I can then use Play.getResourceAsStream() to load files from that directory, or specify the resource as a JVM parameter in the start script (e.g.
-Dconfig.resource=/my_conf/prd.conf
)