Play 2 Java Tutorial
Update: This tutorial is a bit old. For more up-to-date tutorials see: https://www.playframework.com/documentation/2.3.x/Tutorials
I’ve created a Play 2 Tutorial and posted it on GitHub! The tutorial covers how to:
- Create a Play App
- Set up an IDE
- Start the Play Server
- Routes
- Test a Route
- Update a Controller
- Test a Controller
- Update a View
- Test a View
- Deploy your app on the Cloud with Heroku
- Create a Model
- Create UI for Adding Tasks
- Get Tasks as JSON
- Display the Tasks via CoffeeScript and jQuery
- Make the App Pretty with Twitter Bootstrap
- Add Form Validation
- Update the App on Heroku
Each section has a corresponding branch in git so you can diff against my version to see if you’ve done everything correctly. Right now this is just for Play 2 with Java and Ebean but I’m working on doing this for Play 2 with Scala as well.
You can see a live demo of the final app at:
It’s a pretty simple app but it should get you started building Play 2 apps and deploying them on the cloud with Heroku. If you want to take the shortcut to the end and get your own copy of the app running on Heroku then just do the following:
- Install git and the Heroku Toolbelt.
- Signup for an account on Heroku. (Don’t worry, this stuff is free.)
- Clone the play2torial git repo: ```bash git clone git://github.com/jamesward/play2torial.git
4. Login to Heroku: ```bash
heroku login
- Create a new app on Heroku (from within the play2torial directory): ```bash heroku create
6. Upload the app to Heroku (from within the play2torial directory): ```bash
git push heroku origin/java-heroku_update:refs/heads/master
- Check out your app on the cloud: ```bash heroku open
8. If you want to run the app locally, [install Play 2][24] and then run: ```bash
git checkout java-heroku_update
play ~run
I hope this helps you learn Play 2! Let me know if you have any questions or comments. Thanks!