Fork me on GitHub

A simple web framework
for Java and Kotlin

  • Java
  • Kotlin
import io.javalin.Javalin;

public class HelloWorld {
    public static void main(String[] args) {
        Javalin app = Javalin.start(7000);
        app.get("/", ctx -> ctx.result("Hello World"));
    }
}
import io.javalin.Javalin

fun main(args: Array<String>) {
    val app = Javalin.start(7000)
    app.get("/") { ctx -> ctx.result("Hello World") }
}

Why Javalin?

Simple

Unlike other Java and Kotlin web frameworks, Javalin has very few concepts that you need to learn. You never have to extend a class and you rarely have to implement an interface.

Lightweight

Javalin is just a few thousand lines of code on top of Jetty, which means its performance is almost equivalent to pure Jetty. It also means it's very easy to reason about the source code.

Active

A new version of Javalin has been released twice a month (on average) since the first version. Don't worry though, every version is backwards compatible. PRs and issues are reviewed swiftly, normally every week.

Interoperable

Other Java and Kotlin web frameworks offer separate version for each language. Javalin is being developed with interoperability in mind, so apps are built the same way in both Java and Kotlin.

Flexible

Javalin is designed to be simple and blocking, as this is the easiest programming model to reason about. However, if you set a Future as a result, Javalin switches into asynchronous mode.

Educational

Visit our educators page if you're teaching web programming and looking for a web framework which will get out of your way and let you focus on the core concepts of your curriculum.

Declare your server and API
all in one file

  • Java
  • Kotlin
import io.javalin.ApiBuilder.*
import io.javalin.Javalin;

Javalin app = Javalin.create()
    .enableStandardRequestLogging()
    .enableDynamicGzip()
    .port(port)
    .start();

app.routes(() -> {
    path("users", () -> {
        get(UserController::getAllUserIds);
        post(UserController::createUser);
        path(":user-id", () -> {
            get(UserController::getUser);
            patch(UserController::updateUser);
            delete(UserController::deleteUser);
        });
    });
});
import io.javalin.ApiBuilder.*
import io.javalin.Javalin;

val app = Javalin.create().apply {
    enableStandardRequestLogging()
    enableDynamicGzip()
    port(port)
}.start()

app.routes {
    path("users") {
        get(UserController::getAllUserIds)
        post(UserController::createUser)
        path(":user-id") {
            get(UserController::getUser)
            patch(UserController::updateUser)
            delete(UserController::deleteUser)
        }
    }
}

Creating a REST API has never been easier

Built on a solid foundation

Jetty

Javalin runs on top of Jetty, one of the most used and stable web-servers on the JVM. You can configure the Jetty server fully, so you can easily get SSL and HTTP2 and everything else that Jetty has to offer.

SparkJava and Koa.js

Javalin started as a fork of the Java and Kotlin web framework SparkJava, but quickly turned into a ground-up rewrite influenced by the Javascript framework koa.js. Javalin implements lessons learned from working extensively with both of these frameworks.

Like Javalin?