A light-weight Java and Kotlin net framework
Javalin – A light-weight Java and Kotlin net framework
import io.javalin.Javalin;
public class HelloWorld {
public static void most important(String[] args) {
var app = Javalin.create(/*config*/)
.get("https://javalin.io/", ctx -> ctx.outcome("Howdy World"))
.begin(7070);
}
}
import io.javalin.Javalin
enjoyable most important() {
val app = Javalin.create(/*config*/)
.get("https://javalin.io/") { ctx -> ctx.outcome("Howdy World") }
.begin(7070)
}
Easy
Not like different Java and Kotlin net frameworks, Javalin has only a few ideas that it is advisable to be taught.
You by no means lengthen courses and also you hardly ever implement interfaces.
Light-weight
Javalin is only a few thousand strains of code on high of Jetty, and
its efficiency is equal to uncooked Jetty code. Because of its measurement, it is
very straightforward to cause in regards to the supply code.
Interoperable
Different Java and Kotlin net frameworks normally provide one model for every language.
Javalin is being made with inter-operability in thoughts, apps are constructed the identical means in each Java and Kotlin.
Versatile
Javalin is designed to be easy and blocking, as that is the best programming mannequin to cause about.
However, when you set a Future
consequently, Javalin switches into asynchronous mode.
Instructional
Go to our educators page when you’re educating net programming
and in search of an online framework which is able to get out of your means and allow you to deal with the
core ideas of your curriculum.
OpenAPI
Many light-weight Java and Kotlin net frameworks do not help OpenAPI, however Javalin does
(together with Swagger UI and ReDoc). Study extra on the OpenAPI plugin page.
Jetty
Javalin runs on high of Jetty, one of the used and steady web-servers on the JVM.
You may configure the Jetty server totally, together with SSL and HTTP3 and every little thing else
that Jetty affords.
import io.javalin.Javalin;
import static io.javalin.apibuilder.ApiBuilder.*;
public static void most important(String[] args) {
var app = Javalin.create(config -> {
config.useVirtualThreads = true;
config.http.asyncTimeout = 10_000L;
config.staticFiles.add("/public");
config.staticFiles.enableWebjars();
config.router.apiBuilder(() -> {
path("/customers", () -> {
get(UserController::getAll);
publish(UserController::create);
path("/{userId}", () -> {
get(UserController::getOne);
patch(UserController::replace);
delete(UserController::delete);
});
ws("/occasions", userController::webSocketEvents);
});
});
}).begin(7070);
}
import io.javalin.Javalin
import io.javalin.apibuilder.ApiBuilder.*
enjoyable most important() {
val app = Javalin.create { config ->
config.useVirtualThreads = true
config.http.asyncTimeout = 10_000L
config.staticFiles.add("/public")
config.staticFiles.enableWebjars()
config.router.apiBuilder {
path("/customers") {
get(UserController::getAll)
publish(UserController::create)
path("/{userId}") {
get(UserController::getOne)
patch(UserController::replace)
delete(UserController::delete)
}
ws("/occasions", userController::webSocketEvents)
}
}
}.begin(7070)
}
Making a REST API has by no means been simpler
Javalin 1.0 was launched in 2017, and has been in regular growth since.
As of August 2023, the mission consists of round 8000 strains of code and 11 000 strains of exams.
It has nearly 200 contributors, greater than 5 hundred forks, and near seven thousand stars on GitHub.
The mission has round 400 000 downloads per thirty days, and has been launched 132 occasions in 5 years
(about two occasions per thirty days).
Like Javalin?
Star us 😊
×