Setting up your local machine with Java and SBT ready for Play development

Rowan Laurence
Beyond
Published in
3 min readJan 23, 2018

Part two of a series

For this guide we have a repo with all of the code so you can see it in action from a working app, but first you’ll need to install a few things:

Install Java 8 SDK
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

Install Git
https://git-scm.com/

To start, install SBT (Simple build tool)
http://www.scala-sbt.org/

We are going to use Play Framework, you don’t need to download it though as it’s included in the app.

https://www.playframework.com/ — Scala/Java framework
This article refers to the Java Version at version 2.6

We can work with a database in memory — Hello H2
http://www.h2database.com/html/main.html
H2 is already included as part of the app dependencies

For those that don’t know, H2 is a very, very amazing database that runs super fast. Most ORMs connect to it and if you’re working locally, this is the thing to use. It works like a dream and I know it well enough to use it as a counter.

For reference:
https://www.playframework.com/documentation/2.6.x/Home
http://www.scala-sbt.org/0.13/docs/Installing-sbt-on-Mac.html
https://github.com/foundweekends/giter8/wiki/giter8-templates

Once you have SBT installed you can simply clone the git repository, from the command line:

git clone https://github.com/rowanl/playframework-kubernetes.git

This guide will highlight a few parts of this project but if you get lost within it, please refer back to the source code.

Import the project to your IDE. For this run through we are using IntelliJ Idea from Jetbrains — you’ll want the commercial version as it contains Scala support, it’s free for a trial period.

https://www.jetbrains.com/idea/

File > Import project >

Choose the directory where you cloned the project to, and import from the build.sbt file.

Add an application server by choosing:

Run > Edit configurations

Press the plus at the top left, add a new Play2 application, by default you should just need to change the name at the top and save it.

Before you run the application we are going to need to create the assets that serve the CSS, JS and the graphics.

From the command line:

cd front-endnpm installgrunt && grunt watch

Press the run button on your application toolbar. It should start the application and you should see it open up localhost:9000 in a browser.

If you see this page, you’re in business!

Next>> Calling a database from inside Play using Ebean ORM.

--

--

Rowan Laurence
Beyond
Writer for

Technical Director at Beyond San Francisco — Interested in all things digital, scalable software, collecting shoes and dance music