Fork me on GitHub
Follow Spark on Twitter Follow Spark on Google Plus Like us on facebook
Spark framework logo

Spark - A tiny Sinatra inspired framework for creating web applications in Java 8 with minimal effort

Quick Start

import static spark.Spark.*;

public class HelloWorld {
    public static void main(String[] args) {
        get("/hello", (req, res) -> "Hello World");

Run and View


Built for Productivity

Spark Framework is a simple and lightweight Java web framework built for rapid development. Spark's intention isn't to compete with Sinatra, or the dozen of similar web frameworks in different languages, but to provide a pure Java alternative for developers that want to, or are required to, develop their web application in Java.

Spark focuses on being as simple and straight-forward as possible, without the need for cumbersome (XML) configuration, to enable very fast web application development in pure Java with minimal effort. It’s a totally different paradigm when compared to the overuse of annotations for accomplishing pretty trivial stuff seen in other web frameworks, for example, JAX-RS implementations.

Typical Usage

Our 2015 survey tells us that over 50% of Spark users use Spark to create REST APIs, while about 25% use Spark to create webpages. About 15% of deployed Spark applications each serve more than 10.000 users a day. Click here to read the full survey.

Why Use Spark?

If you're a Java developer with neither the urge nor time to learn a new programming language, then Spark might be a great web framework for you. It will have you up and running in minutes, and you won't have to think too much about configuration and boilerplate code (like you often have to in other Java web frameworks, like Spring or Vaadin).

Why Not Use Sinatra?

If you're an experienced Ruby developer, or have experience with languages with similar syntax, you should probably use Sinatra. However, if you're a Java developer and want to get the benefits you get from Sinatra without having to learn a new language, Spark is a very good alternative. Spark is a simple and lightweight Java web framework that doesn't get in your way!

Why Not Go with JAX-RS?

JAX-RS made life easier for Java web developers when it arrived. However, it's a bit messy due to the overuse of annotations for accomplishing pretty trivial things. The annotation magic also makes things more implicit, and it's not always easy to get a clear understanding of what's going on. For people who are new to web frameworks and REST, Spark will have you up and running much faster than using one of the JAX-RS implementations.