Play 2 Java Tutorial
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:
play2torial.herokuapp.com
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:
git clone git://github.com/jamesward/play2torial.git
- Login to Heroku:
heroku login - Create a new app on Heroku (from within the play2torial directory):
heroku create --stack cedar - Upload the app to Heroku (from within the play2torial directory):
git push heroku java-heroku_update:master - Check out your app on the cloud:
heroku open
- If you want to run the app locally, install Play 2 and then run:
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!
About James Ward
James Ward (www.jamesward.com) works for Typesafe where he teaches developers the Typesafe Stack (Play Framework, Scala, and Akka) . James frequently presents at conferences around the world such as JavaOne, Devoxx, and many other Java get-togethers. Along with Bruce Eckel, James co-authored First Steps in Flex. He has also published numerous screencasts, blogs, and technical articles. Starting with Pascal and Assembly in the 80′s, James found his passion for writing code. Beginning in the 90′s he began doing web development with HTML, Perl/CGI, then Java. After building a Flex and Java based customer service portal in 2004 for Pillar Data Systems he became a Technical Evangelist for Flex at Adobe. In 2011 James became a Principal Developer Evangelist at Salesforce.com where he taught developers how to deploy apps on the cloud with Heroku. James Tweets as @_JamesWard and posts code at github.com/jamesward.
More About James »Northern Virginia Software Symposium
November 1 - 3, 2013
Reston, VA
Current Topics on the NFJS Tour
- Core Java, JEE
- Dynamic Languages: Groovy, JRuby, Scala, Clojure
- RESTful Web Apps
- Frameworks: Hibernate, Grails, Spring, JSF, GWT, more
- Agility
- Test Driven Design
- Security
- Ajax, Flex, RIA
Why Attend the NFJS Tour?
- » Cutting-Edge Technologies
- » Agile Practices
- » Peer Exchange
Current Topics:
- Languages on the JVM: Scala, Groovy, Clojure
- Enterprise Java
- Core Java, Java 7
- Agility
- Testing: Geb, Spock, Easyb
- REST
- NoSQL: MongoDB, Cassandra
- Hadoop
- Spring 3
- Automation Tools: Git, Hudson, Sonar
- HTML5, Ajax, jQuery, Usability
- Mobile Applications - iPhone and Android
- More...
NFJS, the Magazine
May Issue Now AvailableOn the road to learning
by Raju GandhiRefactoring to Modularity
by Kirk KnoernschildRESTful Groovy
by Kenneth KousenGetting Started with D3.js
by Brian Sletten