Home Java/J2EE Creating and Developing Project in Play Framework

Creating and Developing Project in Play Framework

Published on April 10, 2014, by in Java/J2EE.

Hi Play Framework beginner,

Play is an open-source modern web framework for writing scalable web applications in Java and Scala. It enables rapid productivity by automatically reloading the changes. Play by design has a stateless and non-blocking architecture. This makes it easy to horizontally scale web applications written using the Play framework.


  • Setup Java 
  • Setup Play

How to Create Project in Play Framework (Here the steps are mentioned for Ubuntu)

  1. Create a directory with any name on your choice of location. Here we created with name “workspace”                                                                      Image 1
  2. Open Terminal and go to the path where you want to store the play Framework Project. As per step #1 we have created “workspace” so lead to that folder in the terminal                Image 2
  3. Now follow these steps of commands to create a new project in play framework
    • Play new [name of your project] : play new Test
    • What is the application name ?: Test
    • Which template do you want to use for this new application? : 2  (select 1 for Scala and 2 for Java)
    • Note: You can create project with Scala or Java template. Play will create the project accordingly
    • Using these steps you have successfully created one Test play applicationImage 3
  4. If you see this, that means you have successfully created your project and now it is time to run the project
  5. Go to your project that we have created recently. In our case project is TestImage 4
  6. Type the command play to get into Play command line                      Image 5
  7. Now Type the command run  to run the project                                      Image 6
  8. If you see this in your console that means you have successfully started your play application on port 9000 (if you want to change the default port follow How to do develop web application using play Framework #3 )
  9. Open the browser and type http://localhost:9000 to open the play web application. It will load the default page of play application                                                                                                                  Image 7

How to do develop web application using Play Framework

  1. First step is to convert your play project structure into the Eclipse project structure
    • Go back to terminal and reach to project path
    • Type following commands in the sequence
    • Play
    • eclipse (convert project for Eclipse IDE, Same way you can also convert for net-beans IDE)
    • run (run the play project)                               Image 8
  2. You can run the play application as background service. Run following command to achieve that
    • play star (once your application start press Ctrl + D)Image 11
    • Now even if you stop your terminal, your application will run in the background
    • To stop the application go back to terminal and reach to project path and type the following command play stop                               Image 12
  3. Now question is how to change default port for play application from 9000 to other. We can achieve this by following command
    • play
    • run 8080                                                 Image 13
    • You can also start server in background with different port type command:
    •  play  start 8080 (then press Ctrl + D)
    • Now your application run on the port 8080Image 14
  4. For any development it is basic requirement on how to start the server in debug mode. It is also possible with Play framework. You just need to run following command.
    • play debug run                                    Image 15
    • Now we can do debug configuration in Eclipse like thisImage 16
    • Apply debug configuration and apply the changes and start the application in debug mode.
Share!Share on FacebookShare on Google+Share on LinkedInTweet about this on TwitterFlattr the authorDigg thisPin on PinterestEmail this to someoneShare on StumbleUponShare on RedditShare on TumblrBuffer this pagePrint this page
Comments Off on Creating and Developing Project in Play Framework.
Copyright © 2017 - Scalsys. All Rights Reserved