Subscribe / Unsubscribe Enewsletters | Login | Register

Pencil Banner

Jump into Java microframeworks, Part 1

Matthew Tyson | Oct. 28, 2015
Go extra lightweight, with Java microframeworks Spark, Ninja, and Play

For true programmers, there is an inherent joy in programming. Our goal is to maximize the time that we spend in the zone, and our tools should help us do just that. No matter what the craft, the ideal tool is an extension of your mind and limbs: without drawing attention to itself, it humbly enables you to do your work better.

In the world of Java web development, such a tool would be described as lightweight. Java microframeworks have recently emerged as the newest and leanest of frameworks yet. Rather than consolidate a massive feature set, as did Java EE, or even a lighter MVC framework like Spring, microframeworks put the programmer at the center of a coherent set of increasingly powerful, lightweight tools.

The RVC stack

I use the term Java microframeworks because it seems to have caught on, but what I am really talking about is a new stack for building Java applications. I sometimes call frameworks like Ninja, Spark, and Play RVC frameworks, because they share a core emphasis on routing, views, and controllers. That emphasis will become clear as we work through the programming demos in this and future articles.

This article is the first in a four-part series. We'll start with an overview of three popular Java microframeworks, Spark, Ninja, and Play. Comparing the frameworks will give you a high-level view of what makes microframeworks tick and where they differentiate. You'll also get started with quick setup instructions and a sample application for each framework. In the next three articles we'll dive into the frameworks individually, building a more complex application that highlights the strongest features of each one.

Three Java microframeworks

Quick takes on Spark, Ninja, and Play.

Name

Basics

More info

Ninja

Mini full-stack framework intended for high scalability

http://www.ninjaframework.org

Spark

Extreme lightweight microframework supporting Java 8

http://sparkjava.com/

Play

The elder micro-stack supporting Java and Scala

https://www.playframework.com/

Now let's take our first look at the Ninja framework.

Ninja: Full stack, high scalability

Ninja installs quickly and painlessly. Just download Ninja from Github and run the provided Maven archetype by typing:

mvn archetype:generate -DarchetypeGroupId=org.ninjaframework -DarchetypeArtifactId=ninja-servlet-archetype-simple

You will be prompted for your group and artifact IDs. Once the the download is complete, you can generate a project for your IDE with a simple Maven command, for example: mvn eclipse:eclipse. Import your new project, and you're ready to code!

To import the project in Eclipse, go to File, and select Import, as shown in Figure 1.

Java Micro Frameworks, Part 1.
Figure 1. Eclipse project import, Step 1

 

1  2  3  4  5  6  7  8  9  10  Next Page 

Sign up for CIO Asia eNewsletters.