Installing Scala — Play Framework on Vagrant

Usually I meshing around with PHP, JS and some frontend JS framework. But today I need to learn a bit for Play Framework for Scala language. Aaaaah…new things you cant leave it behind if you want to stay alive in software engineering.

Anyway, if you want to know more about Scala languange please visit this page, . And for Play Framework you can look at this page, I will not explain anything deeper for those kind of things ( dude… I’m still learning also ).

Before we start, I assumed that you already install and setup Vagrant to your local environment. If you dont know about Vagrant, ask Google. He know (almost) everything. Other is , I’m using ubuntu/trusty64 for my Vagrant box.

1. Edit your VagrantFile.

I will using TypeSafe Activator for installing Play. So you need to setting up proxy port on vagrant and your host system can access it.

[pastacode lang=”haml” message=”” highlight=”” provider=”manual”]
# this is for Play app “forwarded_port”, guest: 9000, host: 9000
# this is for Activator “forwarded_port”, guest: 8888, host: 8888

2. Installing Java ( If in case your not install it ).

Vagrant up and ssh into it, run java -version on your console to check if you’re already installing Java or not, and its must be at least on version 1.8. I will install Java 8 as minimum requirement and since I’m using ubuntu, we need to run this on shell

[pastacode lang=”bash” message=”Checking Java Version” highlight=”” provider=”manual”]
java -version
java version “1.8.0_66”
Java(TM) SE Runtime Environment (build 1.8.0_66-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.66-b17, mixed mode)

[pastacode lang=”bash” message=”Installing Java” highlight=”” provider=”manual”]
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer

3. Installing Play With Activator

By default Play will provide you with Activator application on their download page. If you wanna know about what Activator is, please refer to here Its look like an installer which can help you download resources need for Play and setting those up.

Install it on your vagrant and make sure you have full access permission on the installation path. I’m installing Activator on my home at /home/vagrant/bin/activator-1.3.7-minimal.

Put installation into your PATH. Run it directly on your console or via .bash_profile or .bashrc file

[pastacode lang=”bash” message=”Updating your PATH” highlight=”” provider=”manual”]
export PATH=/home/vagrant/bin/activator-1.3.7-minimal:$PATH

[pastacode lang=”bash” message=”Checking Activator Installation” highlight=”” provider=”manual”]
vagrant@vagrant-ubuntu-trusty-64:/vagrant$ activator — version
sbt launcher version 0.13.8

Test run for your Activator with activator ui command. You need to identified the IP address of your vagrant’s eth0. Just run ifconfig and point to eth0 IP. Than you can access it via your Host browse to http://localhost:8888

[pastacode lang=”bash” message=”Running activator ui” highlight=”” provider=”manual”]
vagrant@vagrant-ubuntu-trusty-64:/vagrant$ activator ui -Dhttp.address=
Local repository: activator-launcher-local @ file:/home/vagrant/bin/activator-1.3.7-minimal/repository
Play server process ID is 5910
[info] play — Application started (Prod)
[info] play — Listening for HTTP on /
[info] a.e.s.Slf4jLogger — Slf4jLogger started
Unable to open a web browser!
Please point your browser at:

For installing Play, go to your desired workspace folder and run command below. And choose play-scala for template, and wait for rest of process ( quite take a long time to download at the first time ).

[pastacode lang=”bash” message=”Create new play scala project” highlight=”” provider=”manual”]
vagrant@vagrant-ubuntu-trusty-64:/vagrant/workspace$ activator new just-test

Fetching the latest list of templates…

Browse the list of templates:
Choose from these featured templates or enter a template name:
1) minimal-akka-java-seed
2) minimal-akka-scala-seed
3) minimal-java
4) minimal-scala
5) play-java
6) play-scala
(hit tab to see a list of all templates)

After succesfully installation, go to your project folder. For me its on /vagrant/workspace/just-test. And run command below

[pastacode lang=”bash” message=”Running your project” highlight=”” provider=”manual”]
vagrant@vagrant-ubuntu-trusty-64:/vagrant/workspace/just-test$ activator run
[info] Loading project definition from /vagrant/workspace/just-test/project
[info] Updating {file:/vagrant/workspace/just-test/project/}just-test-build…
[info] Resolving org.fusesource.jansi#jansi;1.4 …
[info] Done updating.
[info] Set current project to just-test (in build file:/vagrant/workspace/just-test/)
[info] Updating {file:/vagrant/workspace/just-test/}root…
[info] Resolving jline#jline;2.12.1 …
[info] Done updating.

— — (Running the application, auto-reloading is enabled) — -

[info] p.c.s.NettyServer — Listening for HTTP on /0:0:0:0:0:0:0:0:9000

(Server started, use Ctrl+D to stop and go back to the console…)

Open your browser on Host machine and goto http://localhost:9000.

[caption id=”attachment_5" align=”alignnone” width=”300"]

Play framework starter page

Play framework starter page[/caption]

And you are ready to Play.