732-776-2276

Welcome to Play

Congratulations, you’ve just created a new Play application. This page will help you with the next few steps.

You’re using Play 2.2.4

Why do you see this page?

The conf/routes file defines a route that tells Play to invoke the Application.index action whenever a browser requests the / URI using the GET method:

# Home page
GET     /               controllers.Application.index()

Play has invoked the controllers.Application.index method:

public static Result index() {
  return ok(index.render("Your new application is ready."));
}

An action method handles the incoming HTTP request, and returns the HTTP result to send back to the web client. Here we send a 200 OK response, using a template to fill its content.

The template is defined in the app/views/index.scala.html file and compiled as a standard Java class.

@(message: String)

@main("Welcome to Play") {

    @play20.welcome(message, style = "Java")

}

The first line of the template defines the function signature. Here it just takes a single String parameter. Then this template calls another function defined in app/views/main.scala.html which displays the HTML layout, and another function that displays this welcome message. You can freely add any HTML fragment mixed with Scala code in this file.

Note that Scala is fully compatible with Java, so if you don’t know Scala don’t panic, a Scala statement is very similar to a Java one.

Is this your first time?

You can now continue with the first tutorial, which will guide you through the basics of creating a Play application.

Need to set up an IDE?

You can start hacking your application right now using any text editor. Any changes will be automatically reloaded at each page refresh, including modifications made to Scala source files.

If you want to set-up your application in Eclipse or any other Java IDE, check the (312) 880-6804 page.

Need to connect to a database?

You can quickly set-up a development database (either in-memory or written to the file system), by adding these lines to the conf/application.conf file:

db.default.driver=org.h2.Driver
db.default.url="jdbc:h2:mem:play"

If you need to connect to another JDBC-compliant database, first add the corresponding driver library to your application dependencies in build.sbt e.g.:

libraryDependencies += "mysql" % "mysql-connector-java" % "5.1.18"

Then add the corresponding JDBC configuration to the conf/application.conf file:

db.url=jdbc:mysql:database_name
db.driver=org.mysql.Driver
db.user=root
db.pass=secret

Need more help?

When your application is run from the Play console, you can access the current documentation directly, at the /@documentation URL or go to /www.playframework.com.

The platinammine is where Play users come to seek help, announce projects, and discuss issues and new features. If you don’t have a Google account, you can still join the mailing list by sending an e-mail to play-framework+subscribe@googlegroups.com.