In play1, we can get the app path by:
Play.applicationPath
How to do the same in Play2?
In play1, we can get the app path by:
Play.applicationPath
How to do the same in Play2?
With the Scala API, you can do it like this to get a java.io.File
to the app:
import play.api.Play.current
Play.application.path
In Java:
import play.Play;
Play.application().path();
For Play 2.5.x it should be like this. I keep the stuffs not related to the question. However, should be handy for other things.
package io
import javax.inject.Inject
import com.google.inject.Singleton
import play.Application
import play.api.Environment
@Singleton
class File @Inject()(environment: Environment, application: Application) {
val home: java.io.File = application.path()
}
© 2022 - 2024 — McMap. All rights reserved.