How to install the Play Web Framework for Java and Scala on Ubuntu 12.04 LTS

Play is an open source web application framework for Java and Scala, which follows the model-view-control architectural model. This article will assume that you already have Java and/or Scala installed. If you don’t, check out our knowledge base article on how to install Java and Scala.

We will install Play 2.1.3, which is the latest version available as of this article.

SSH to your Pod, and run the follow as root (or use sudo):

root@mypod:~# wget
root@mypod:~# sudo apt-get install unzip
root@mypod:~# unzip
root@mypod:~# sudo mv play-2.1.3 /opt
root@mypod:~# sudo ln -s /opt/play-2.1.3/ /opt/play
root@mypod:~# sudo ln -s /opt/play/play /usr/local/bin/play

Now, let’s have Play generate our first application for us, and then run it. It will ask whether you want to generate Java or Scala code, you can choose whichever you prefer:

root@mypod:~# play new myFirstApp
root@mypod:~# cd myFirstApp
root@mypod:~# play

Once this has finished, you will be inside the Play console. You can type “run” to run the application in debug mode:

[myFirstApp] $ run

The application will now be running on port 9000, and you can test it by going to http://youripaddress:9000. If you don’t know your ip address, open up another ssh session and run the follow command to learn it:

root@mypod:~# ifconfig eth0 | grep inet | awk '{ print $2 }'

The first time running the application will take a moment, as the Java and Scala source will have to compile. You should see a page that says “Your new application is ready” and welcomes you to Scala.

You can learn more about Play at their web site. Have fun!

Matthew McCaffrey

Leave a Reply