At the moment I’m working with a team on a Play! Framework app. With the next user story, I have to implement some different file modifications, such as moving a file to a defined directory.
Because we are working on different platforms, I’m not always really sure if the app has the right path. So I want to work with a absolute path of the app directory.
How do I get the absolute path of a Play! app? Is there a method for this?
This answer applies only to older versions of the Play Framework, before v2.
Play has an application path property:
This will give you the directory that Play is running from.
I think a better practice is moving the directory outside of your project install directory and placing the path to it in your
application.confas a property. You then retrieve it when needed. For example:Application.conf:
Code: