Wednesday, October 14, 2015

Setup Play Framework and TypeSafe on centOS

I'm going to setup simple project based on Play Framework together with Cassandra on two centOS servers.

I'm going to do 3 steps during that process:
  1. Install Java
  2. Install Typesafe activator
  3. Create test project.

Installing Java

//1. go to opt folder
cd /opt

//2. download java
wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u60-b27/jdk-8u60-linux-x64.tar.gz"

//3. extract java archive
tar xzf jdk-8u60-linux-x64.tar.gz

//4. installing java
cd /opt/jdk1.8.0_60/
alternatives --install /usr/bin/java java /opt/jdk1.8.0_60/bin/java 2
alternatives --config java

//5. recommended options: setup javac and jar
alternatives --install /usr/bin/jar jar /opt/jdk1.8.0_60/bin/jar 2
alternatives --install /usr/bin/javac javac /opt/jdk1.8.0_60/bin/javac 2
alternatives --set jar /opt/jdk1.8.0_60/bin/jar
alternatives --set javac /opt/jdk1.8.0_60/bin/javac

//6. setup variables so we can access java from everywhere
export JAVA_HOME=/opt/jdk1.8.0_60
export JRE_HOME=/opt/jdk1.8.0_60/jre
export PATH=$PATH:/opt/jdk1.8.0_60/bin:/opt/jdk1.8.0_60/jre/bin

//7. checking java version
java -version

//8. delete java archive
rm jdk-8u60-linux-x64.tar.gz

Installing Play Framework / TypeSafe


Example is about current version, which is 1.3.6
//1. go to tmp folder and download typesafe activator
cd /tmp
wget https://downloads.typesafe.com/typesafe-activator/1.3.6/typesafe-activator-1.3.6.zip

//2. unzip and move to opt folder
unzip typesafe-activator-1.3.6.zip
mv activator-dist-1.3.6 /opt

//3. delete zip file, we do not need it anymore
rm typesafe-activator-1.3.6.zip

//4. create soft symbolic link from /opt/activator-dist-1.3.6/activator to /usr/local/sbin/activator
ln -s /opt/activator-dist-1.3.6/activator /usr/local/sbin/activator

//5. set variables so we can use activator from everywhere
export PATH=/usr/local/sbin/activator:$PATH

Create helloworld project


Time to create our first project. Play Framework provides many templates, we are going to use play-java (it has already web interface and some code, so we can discover it).
//1. create folder www in /var (we are going to keep projects there).
cd /var
mkdir www
cd www

//2. have a look on current templates
activator list-templates

//3. create a new project based on play-java template
activator new helloworld play-java

//4. go into newly created project and run it
cd helloworld
activator run

If activator run properly, you should see something like this:


Now you are ready to open project in browser. Type 127.0.0.1:900 and boooom, we have it ready!


I'm going to play with centOS little bit more (before I start to look on code). I already have some minor issues I want to optimise.

1 comment :

Durante said...

Thanks for posting such an excellent informative content.