To follow the steps in this tutorial, you will need the correct version of Java and sbt. The tutorial requires:
- Java Software Developer's Kit (SE) 11 or higher
- sbt 1.9.6 or higher.
To check your Java version, enter the following in a command window:
java -version
To check your sbt version, enter the following in a command window:
sbt sbtVersion
If you do not have the required versions, follow these links to obtain them:
This example Play project was created from a seed template. It includes all Play components and an Akka HTTP server. The project is also configured with filters for Cross-Site Request Forgery (CSRF) protection and security headers.
To build and run the project:
-
Use a command window to change into the example project directory, for example:
cd play-java-hello-world-tutorial
-
Build the project. Enter:
sbt run
. The project builds and starts the embedded HTTP server. Since this downloads libraries and dependencies, the amount of time required depends partly on your connection's speed. -
After the message
Server started, ...
displays, enter the following URL in a browser: http://localhost:9000
The Play application responds: Welcome to the Hello World Tutorial!
By default, the project uses the Akka HTTP Server backend. To switch to the Netty Server backend, enable the PlayNettyServer
sbt plugin in the build.sbt
file.
In the build.sbt
of this project, you'll find a commented line for this setting; simply uncomment it to make the switch.
For more detailed information, refer to the Play Framework documentation.