.

Friday, May 10, 2013

Getting Started with Play Framework : Ubuntu/Linux Mint

What is Play Framework ?

Play Framework is a simple and powerful web development framework for Java/Scala. It’s very inspired from Ruby On Rails framework, so it’s like Rails, but for Java/Scala (initially it supported only Java, but now it also supports Scala (a programming language, very similar to Java, with some functional features, designed to be as a better Java)). Unlike other complicated java web development frameworks, Play is very simple and highly productive. play-logo Play is a lightweight, fast and highly scalable web development framework, with web friendly architecture and features (stateless, low resource consumption, reactive model based on Iteratee IO etc). So if you’re a Java/Scala developer, who want to develop cool web applications – then Play is a great choice for you.

Installing Play Framework

You must have Java installed (JDK 6 or later), read this tutorial on installing JDK in Ubuntu / Linux Mint if you haven’t already done that. When you’re done setting up java development kit, open a terminal and typejavac to make sure everything is setup properly. Download Play FrameworkDownload the latest version of Play (currently, it’s v2.1.0) and extract it to your Home Directory (it can be anywhere, but you should have write permission). Set Path Variable for Play Add the play to your path variable. Suppose, you have extracted the play framework to ~/packages/play-2.1.0 directory. Then open a terminal and type :
export PATH=$PATH:~/packages/play-2.1.0/
Now, if you type play at the terminal, you should have play command available.



play-command

Creating your first app

Now, you have successfully installed the play framework – Let’s create a simple application “TestApp” (it will simply say : “Hello Play”, not any useful, but you get an overview).
play new TestApp
Now, it will prompt for few questions (Application Name, Java/Scala etc), then move into the application directory and start the application.
cd TestApp
play
Now, you will have the play prompt, So you can run the application -
[TestApp]$ run
Open your browser and type the address http://localhost:9000, the default page should appear. welcome-play-app
Now, open the file App/Controllers/Application.java in your favorite text editor (Emacs, Vi, gedit etc) or IDE (geany, Eclipse etc) and replace the existing return line (in index method) with this :
return ok("Hello Play");
Now, visit the address http://localhost:9000 (or refresh if it’s slready loaded) and you should see the “Hello Play” greetings. Yeah! our first useless app is running :)hello-play source : http://blog.sudobits.com/2013/03/02/getting-started-with-play-framework-ubuntu-linux-mint/

| Free Bussines? |

1 comment: