Use this tag for programming questions about the Javalin web framework for Java and Kotlin.
Overview
Javalin is a lightweight web framework built on the Jetty web server.
The framework can be integrated into Java and Kotlin projects.
Javalin supports several template engines including Thymeleaf and Velocity. It has built-in support for WebSockets, HTTP2, static file serving, exception mapping, server-sent events, asynchronous mode, as well as a variety of common tasks such as validation, access control, logging, and server configuration.
An OpenAPI (Swagger) plugin is also provided, as well as a GraphQL plugin.
Resources
Hello World
Java:
import io.javalin.Javalin;
public class HelloWorld {
public static void main(String[] args) {
Javalin app = Javalin.create().start(7070);
app.get("/", ctx -> ctx.result("Hello World"));
}
}
Kotlin:
import io.javalin.Javalin
fun main() {
val app = Javalin.create().start(7070)
app.get("/") { ctx -> ctx.result("Hello World") }
}