New to Play?
» Learn whether Play Framework is right for your project
» Try the Hello World Tutorial
The Java and Scala Hello World projects are self-contained tutorials that include a distribution of the sbt build tool.
Play requires Java 8 or higher. Check your version with the java -version
command and if needed, install it from Oracle's site.
To try the tutorial, first download the Java or Scala project:
Play 2.8.x Hello World Projects | ||
---|---|---|
Play Java Hello World Tutorial | Download (zip) | View on GitHub |
Play Scala Hello World Tutorial | Download (zip) | View on GitHub |
To run the tutorial:
- Unzip the project in a convenient location.
- In a command window, change to the top-level project directory.
- Enter
sbt run
. - After the message
Server started, ...
displays, enter the following URL in a browser: http://localhost:9000
The tutorial welcome page displays.
Already know a bit about Play?
Lightbend Tech Hub offers a variety of Play example projects for Java and Scala that are focused on a particular use case. The downloadable zip files include everything you need, including sbt, Play Framework, and an HTTP server. The examples also support Gradle.
If you are ready to start your own project and have sbt installed, you can create a Play project from the command line.
» Try a focused example
Follow these steps to try an example project:
- Check that your Java version is 8 or higher with the
java -version
command and if needed, install it from Oracle's site. - Choose an example from Lightbend's Tech Hub.
- Click "CREATE A PROJECT FOR ME" to download the zipped project.
- Unzip the project in a convenient location.
- In a command window, navigate to the top level project directory.
- Enter one of the following commands:
- On macOS or Linux systems:
./sbt run
or./gradlew runPlayBinary
- On Windows systems:
sbt.bat run
orgradlew.bat runPlayBinary
- On macOS or Linux systems:
- The build tool downloads dependencies and compiles the project.
- After the build finishes, enter the following URL in a browser to view the app: http://localhost:9000/
Check out the README.md
file in the top level project directory to learn more about the example.
» Create a Play Java or Scala project using sbt new
In a command window, enter one of the following and respond to the prompts to create a new project:
Java seed template
sbt new playframework/play-java-seed.g8
Scala seed template
sbt new playframework/play-scala-seed.g8
After the template creates the project:
- Change into the top level project directory.
- Enter
sbt run
to download dependencies and start the system. - In a browser, enter http://localhost:9000 to view the welcome page.