Javalin
By Javalin community
Javalin is a lightweight web framework for Java and Kotlin that provides a simple, functional API for building HTTP servers and REST APIs on top of the Jetty engine without imposing a heavyweight architecture. It is distributed as a small…
Definition
Javalin is a lightweight web framework for Java and Kotlin that provides a simple, functional API for building HTTP servers and REST APIs on top of the Jetty engine without imposing a heavyweight architecture. It is distributed as a small library rather than a full-stack platform, giving developers direct control over routing, middleware, and JSON handling while adding minimal abstraction over the underlying servlet and Jetty APIs it wraps.
Overview
Javalin was created to fill a gap between minimalist microframeworks like Spark Java, which had become less actively maintained, and heavier frameworks like Spring Boot, which bring dependency injection, auto-configuration, and a large learning curve. Its design goal is to let a developer define an HTTP server in a handful of lines using lambda-based route handlers, while remaining a thin wrapper that stays close to the underlying Jetty and Java Servlet APIs rather than hiding them behind layers of abstraction. Mechanically, a Javalin application is created by instantiating a `Javalin` object, registering routes with methods like `get`, `post`, and `before` that take a `Context` object exposing request and response data, and then calling `start()` to bind an embedded Jetty server to a port. Because it targets both Java and Kotlin equally, its API relies on lambdas and method chaining rather than annotations, which keeps route definitions visible in one place instead of scattered across annotated classes. JSON serialization, WebSocket support, static file serving, and OpenAPI documentation are available as built-in features or through small plugins rather than a large plugin ecosystem. Javalin occupies a similar niche to Spark Java, which it is often compared to and considered a spiritual successor of given Spark's slower release cadence, while sitting well below Dropwizard and Spring Boot in terms of built-in operational features like metrics and health checks. Unlike Micronaut or Quarkus, it does not provide dependency injection or ahead-of-time compilation, and unlike full Jakarta EE servers, it has no concept of managed beans or container-provided services — the developer wires everything explicitly in code. In practice, Javalin is used for small services, prototypes, teaching HTTP fundamentals, and situations where a team wants a REST API without adopting a large framework's conventions. Its equal support for Kotlin has made it popular in the Kotlin community specifically, where idiomatic lambda syntax makes route definitions especially concise. Because it has few dependencies beyond Jetty and Jackson, startup times are fast and the mental model stays small enough for a single developer to hold in their head. The main trade-off is that Javalin deliberately does not solve problems it considers out of scope: it has no built-in dependency injection container, no ORM integration, no built-in clustering or service discovery, and configuration management is left to whatever the developer chooses. For a small service this simplicity is an advantage, but for a large team building many interdependent services, the lack of enforced structure and larger platform features found in Spring Boot or Micronaut can shift more architectural decisions and boilerplate onto individual teams.
Key Features
- Provides lambda-based route definitions for both Java and Kotlin
- Wraps the embedded Jetty server with minimal added abstraction
- Requires no annotations, keeping routing logic visible in one place
- Supports WebSocket endpoints alongside standard HTTP routes
- Includes built-in JSON serialization via Jackson by default
- Offers optional OpenAPI documentation generation through plugins
- Starts quickly due to a small, focused dependency footprint
- Exposes a Context object unifying request and response handling