Skip to content

setting up your development environment

opensas edited this page Mar 12, 2012 · 6 revisions

Setup your development environment

Play doesn't really have a "development environment" to set. The whole thing can be as simple as:

wget http://download.playframework.org/releases/play-1.2.3.zip
unzip play-1.2.3.zip

So in the end it's just a matter of taste. Here I'll introduce my favorite setup.

Preparing directories

I like to work with the following directory structure

~/devel          # all my development stuff
  /apps          # every play app
  /downloads     # installable packages
  /opt           # here I install stuff
    /eclipse-version
    /play-x.x.x
    /play-y.y.y
    /jdk1.x.X

and then I create soft link to the installed apps. This way is really easy to change versions, just have to change the link and that's it.

Install java

Play needs java 5 or later, as stated in the installation guide.

play comes with it's own compiler, so you can work ok with the jre (java runtime edition). However I prefer to go with the jdk (java development kit)

So, download the jdk compressed binary from oracle's web site to ~/devel/downloads, and then

cd ~/devel/opt
tar -xvf ../downloads/jdk-7-linux-i586.tar.gz
cd ~/devel
ln -s opt/jdk1.7.0/ jdk
ln -s jdk/jre/ jre

then edit you .profile file (for example with vim vim ~/.profile) adding the following lines at the end of the file

export JAVA_HOME="$HOME/devel/jre"
export JDK_HOME="$HOME/devel/jdk"

PATH="$JAVA_HOME/bin:$PATH"

save the file, source it and try it

cd ~
source .profile
java -version
java version "1.7.0"
Java(TM) SE Runtime Environment (build 1.7.0-b147)
Java HotSpot(TM) Client VM (build 21.0-b17, mixed mode)

Now you have a working java installation

Of course, you can also install it using you OS package manager, in debian bases distributions

sudo apt-get install openjdk-7-jdk

Install play framework

Download play framework and unzip it to opt directory

cd ~/devel/downloads
wget http://download.playframework.org/releases/play-1.2.3.zip
cd opt
unzip ~/devel/downloads/play-1.2.3.zip

then create the link at devel directory

cd ~/devel
ln -s opt/play-1.2.3 play

finally update .profile file, add the following line

PATH="$HOME/devel/play:$JAVA_HOME/bin:$PATH"

source your .profile file and test the installation

cd ~
source .profile
play version
~        _            _ 
~  _ __ | | __ _ _  _| |
~ | '_ \| |/ _' | || |_|
~ |  __/|_|\____|\__ (_)
~ |_|            |__/   
~
~ play! 1.2.3, http://www.playframework.org
~
1.2.3

that's it

Install eclipse

Go to eclipse web site and download the Eclipse Classic edition to ~/devel/downloads folder. Then uncompress it and create the symlink

cd ~/devel/opt
tar -xvf ../downloads/eclipse-SDK-3.7-linux-gtk.tar.gz
cd ~/devel
ln -s opt/eclipse eclipse

play framework also comes with an eclipse plugin, just copy it from play's installation directory to eclipse dropins directory, like this:

cp <play dir>/support/eclipse/org.playframework.playclipse_0.7.0.jar <eclipse dir>/dropins/

Of course, you can also install it using you OS package manager, in debian bases distributions

sudo apt-get install eclipse

Final setup

this is how my ~/devel folder looks like

ls -la ~/devel

total 24
drwxrwxr-x  6 sas sas 4096 2011-09-11 05:37 .
drwxr-xr-x 30 sas sas 4096 2011-09-11 05:18 ..
drwxrwxr-x  3 sas sas 4096 2011-09-11 05:19 apps
drwxrwxr-x  2 sas sas 4096 2011-09-11 05:16 downloads
lrwxrwxrwx  1 sas sas   19 2011-09-11 05:35 eclipse -> opt/eclipse-indigo/
lrwxrwxrwx  1 sas sas   13 2011-09-11 05:37 jdk -> opt/jdk1.7.0/
lrwxrwxrwx  1 sas sas    8 2011-09-11 05:37 jre -> jdk/jre/
drwxrwxr-x  6 sas sas 4096 2011-09-11 05:47 opt
lrwxrwxrwx  1 sas sas   15 2011-09-11 05:13 play -> opt/play-1.2.3/

sas@sas-box:~$ echo $PATH
/home/sas/devel/play:/home/sas/devel/jre/bin:/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games

sas@sas-box:~$ echo $JAVA_HOME
/home/sas/devel/jre

sas@sas-box:~$ echo $JDK_HOME
/home/sas/devel/jdk

Some extras (not needed, but highly desirable)

A source code control system is almost a must nowdays, and git is one great choice for such a job. With github, it provides everything you need to start open source projects.

Follow this github guide to get you up and running.

Also if you rather use a graphical git client, you might want to have a look at syntevo's git client.


that's it, now you can go to Step 0 - create an empty project to create your first play application.