Workshop: AngularJS, HTML5, Groovy, Java and MongoDB

Setup required for the AngularJS/HTML5/Groovy/Java/MongoDB tutorial for QCon London 2015. Sign up with code SPEAKGEE100 for £100 off the price!

Who is this for?

This workshop is aimed at Java developers who want to learn more about how to rapidly prototype applications using web front-end technologies with JVM back-end technologies. The workshop may be suitable for developers who don’t normally use Java as their primary language, but this is not an introduction to Java and familiarity with server-side development of some kind is assumed.

A basic understanding of HTML and JavaScript is expected, but previous experience of Groovy or MongoDB is not required.

The workshop is not suitable for people who have no programming experience.

This is a hands-on workshop, bring a laptop set up according to the following instructions - you will be writing code!

Overview

I’ve created my very first screencast! This video takes you through all the steps you need to go through in order to be setup for the workshop.

The setup instructions below are the same process, so you can copy & paste where appropriate.

Setup

I am assuming you already have a version of the Java SDK downloaded. For this workshop, Java 7 or above should work, but I recommend you download the latest version of Java 8 if you’re not already using it.

Create a new work area for this tutorial. For the rest of these instructions I’ll refer to it as <location>. I’ve put mine in ~/Projects/workshops/qcon2015

Installing MongoDB

I’m going to be using MongoDB 3.0.0-rc8, but version 2.6 will be fine too.

Download MongoDB for your operating system and unzip/install it. Unless you prefer to put it somewhere else, I suggest you unzip it to <location>/mongodb

Now we have to create the directory for the data to go into. Create a data directory in <location>, so that you have a folder at <location>/data

From the command line, start MongoDB to make sure everything is working. From the <location> directory:

Linux/OSX
./mongodb/bin/mongod --dbpath data 
Windows:
monogdbbinmongod.exe --dbpath data 

MongoDB should be running on localhost and port 27017

Connect to the shell to make sure it’s working:

Linux/OSX
./mongodb/bin/mongo 
Windows
monogdbbinmongo.exe 

You should see something like:

~Projectsworkshopsqcon2015>monogdbbinmongo.exe MongoDB shell version: 2.8.0-rc5 connecting to: test Welcome to the MongoDB shell. For interactive help, type "help". For more comprehensive documentation, see         http://docs.mongodb.org/ Questions? Try the support group         http://groups.google.com/group/mongodb-user > 

Creating your project

Clone the Cafelito project into <location>/cafelito

In a terminal/command line, navigate to this location, and run:

Linux/OSX
./gradlew check 
Windows
gradlew.bat check 

This should download all the required dependencies.

Open in your favourite IDE and import this directory as a new project. I’ll be using IntelliJ IDEA 14 and showing a number of its tricks. If you’re using IntelliJ IDEA and you import this project as a Gradle project, you don’t even need to do the above step, IntelliJ will download and import the dependencies for you.

Feel free to use Eclipse or Netbeans (or whatever your favourite IDE is) but I’m out of practice using those IDEs and might not be able to help you out as much.

And now…

You should be ready to begin: you have a working instance of MongoDB, a skeleton project that we’ll be working with, and all the dependencies should have been downloaded.

Author

  • Trisha Gee

    Trisha is a software engineer, Java Champion and author. Trisha has developed Java applications for finance, manufacturing and non-profit organisations, and she's a lead developer advocate at Gradle.