Building a data visualization app in Java

25th November, 2014

spring1Earlier in this blog, we went into some detail on how to integrate KeyLines’ network visualization capability into a Java application using Google Web Tools (GWT).

As part 2 in the series, we explain how to get KeyLines data visualization capability running in your Spring project.

Step 1: Understand Spring

There’s no shortage of Java frameworks out there, trying to tempt overstretched enterprise developers, crying for help from beneath their mountains of code. Top of the pile, in terms of market share at least, is the Spring framework.

Spring is a simple, stable and elegant platform for Java applications. In its own words, Spring ‘handles the infrastructure so you can focus on your application.’ It makes the process of building an enterprise web application with rich front-end simpler, faster and much less code-heavy.

With Spring you can either use regular POJOs or Spring Beans to model the logic, making integration with other frameworks as simple as possible – including the Spring Data Neo4j, a delightful project that makes building Java graph applications on top of your Neo4j graph database simpler.

Step 2: Start the Spring tutorial

One of the best things about Spring is how simple it is to start a project:

1. Choose Spring Starter Project

Spring starter project

2. Choose a name for the project

Spring project name

3. Tick the ‘web’ checkbox in the panel at the bottom.
You should end up with most of your application code and the following file structure (shown in an Eclipse environment):

Spring file structure

Once you’ve created the project, add the WebController file (see step 3) and the index.html in the resources folder (see step 4).

Step 3: Create the controller class

Next up, you need to create a simple controller class to serve the HTML page:

package your.application.controller.package;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
public class WebController extends WebMvcConfigurerAdapter {
    @RequestMapping(value="/", method=RequestMethod.GET)
    public String showPage() {
        return "index";

Step 4: Serve your web page

The Controller will serve the following index.html file containing the KeyLines component, which is insides rc/main/resource/template

    Spring and KeyLines together! 

Spring and KeyLines together!

Step 5: Run your application

Run the application from the IDE – we use Eclipse here – and point your browser to http://localhost:8080/:


And that’s it!

screenshot data visualization in spring

In five simple steps we’ve got KeyLines running in a Java environment.

If you would like an evaluation of KeyLines to give it a go for yourself, just get in touch with some information about your project. We’d love to hear from you!

Subscribe to our newsletter

Get occasional data visualization updates, stories and best practice tips by email