If you’re using a 0.5.X version of Javalin, you can go ahead and upgrade to 1.0.0 — it shouldn’t break anything.

Javalin: “more library than framework”

This very lightweight web framework for Kotlin and Java was inspired by Sparkjava and koa.js, according to the blog post announcing the 1.0 release. Javalin is written in Kotlin “with a few functional interfaces written in Java. This was necessary to provide an enjoyable and near identical experience for both Kotlin and Java developers.”

Javalin is really more library than framework.

The best part about Javalin is that you don’t have to extend or implement anything. Furthermore, there are just a few “Javalin-concepts” that you’ll have to learn.

So is it a framework or a library?

Javalin was originally a fork of the Spark Java and Kotlin web framework but then it became a ground-up rewrite influenced by koa.js.

All of these web frameworks are inspired by the modern micro web framework grandfather: Sinatra, so if you’re coming from Ruby then Javalin shouldn’t feel too unfamiliar.

In the end, Javalin aims to be a lightweight REST API library. Although there’s no concept of MVC, there is support for template engines, websockets, and static file serving for convenience which allows you to use Javalin for both creating your RESTful API backend, as well as serving an index.html with static resources.

Hello World

Kotlin

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

Java

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

There are a bunch of examples in the Javalin blog post so check them out if you want to understand why Javalin is for both Kotlin and Java developers.

Javalin takes the interoperability between Kotlin and Java seriously, so you don’t need to turn your world upside down when moving a Javalin project from Java to Kotlin. If you’ve already looked at the examples, you probably saw that everything is more or less the same when you switch between Kotlin and Java (with the exception of some parentheses and semicolons).

After all, maintaining this consistent API for both Kotlin and Java is an important goal of Javalin.