<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom"><title>thermcampos blog » java</title><link href="https://thermcampos.blog/" rel="alternate"/><link href="https://thermcampos.blog/atom/java/" rel="self"/><id>/atom/java/</id><updated>2026-10-01T18:15:11Z</updated><author><name>R. Campos</name></author><subtitle>Welcome to my blog, personal corner and stuff</subtitle><entry><title>Javalin the lightweight java framework</title><link href="https://thermcampos.blog/post/javalin-java-framework/" rel="alternate"/><published>2026-10-01T18:15:11Z</published><updated>2026-10-01T18:15:11Z</updated><author><name>R. Campos</name><email>ricardompcampos@gmail.com</email></author><id>/post/javalin-java-framework/</id><summary type="html">&lt;!-- tags: java --&gt;
&lt;!-- date: 2026-10-01 18:15:11 --&gt;
&lt;img alt="/attachments/javalin-the-lightweight-java-framework-header.png" src="/attachments/javalin-the-lightweight-java-framework-header.png" /&gt;
&lt;p&gt;I'd like to introduce you all to &lt;a class="reference external" href="https://javalin.io/"&gt;Javalin&lt;/a&gt;. Java is known for being heavy and
bloated, verbose, often flagged as bad choice for cold-start functions, or
simple MVPs or POCs. Often because it's slow, or memory-heavy consumer, which
I could agree with, on some situations.&lt;/p&gt;
&lt;p&gt;This is specially interesting if you're coming from languages such as Go or
Typescript and is already familiar with express.js or chi from Golang. The
learning curve for a full Java backend app will be pretty smooth.&lt;/p&gt;
</summary><content type="html">&lt;!-- tags: java --&gt;
&lt;!-- date: 2026-10-01 18:15:11 --&gt;
&lt;img alt="/attachments/javalin-the-lightweight-java-framework-header.png" src="/attachments/javalin-the-lightweight-java-framework-header.png" /&gt;
&lt;p&gt;I'd like to introduce you all to &lt;a class="reference external" href="https://javalin.io/"&gt;Javalin&lt;/a&gt;. Java is known for being heavy and
bloated, verbose, often flagged as bad choice for cold-start functions, or
simple MVPs or POCs. Often because it's slow, or memory-heavy consumer, which
I could agree with, on some situations.&lt;/p&gt;
&lt;p&gt;This is specially interesting if you're coming from languages such as Go or
Typescript and is already familiar with express.js or chi from Golang. The
learning curve for a full Java backend app will be pretty smooth.&lt;/p&gt;
&lt;!-- read_more --&gt;
&lt;p&gt;Let's cut to the chase, no rambling, no time spent. Javalin is simple,
lightweight, interoperable, flexible, supports OpenAPI and runs on
top of Jetty JVM web-server, that includes SSL and HTTP3.&lt;/p&gt;
&lt;p&gt;Here's what a Hello World would look like, if you're curious.&lt;/p&gt;

&lt;pre class="brush: java"&gt;
import io.javalin.Javalin;

void main() {
  var app = Javalin.create(config -&gt; {
    config.routes.get("/", ctx -&gt; ctx.result("Hello World"));
  }).start(7070);
}
&lt;/pre&gt;

&lt;p&gt;And that's it! No &lt;em&gt;annotations&lt;/em&gt; needed, controllers, or any of the boilerplate
that Springs like. As simple as that.&lt;/p&gt;
&lt;p&gt;If you're a &lt;strong&gt;maven&lt;/strong&gt; person, you can get started in the &lt;a class="reference external" href="https://javalin.io/tutorials/maven-setup"&gt;maven-setup page&lt;/a&gt;,
but if you're a &lt;strong&gt;graddle&lt;/strong&gt; person, use the &lt;a class="reference external" href="https://javalin.io/tutorials/gradle-setup"&gt;graddle-setup page&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;a class="reference external" href="https://javalin.io/tutorials/"&gt;On their page&lt;/a&gt; there's plenty of useful tutorials and code snippets, check it
out. And now if you want to go straight to the code, find their GitHub repo at:
&lt;a class="reference external" href="https://github.com/javalin/javalin"&gt;https://github.com/javalin/javalin&lt;/a&gt;&lt;/p&gt;
&lt;div class="section" id="native-build"&gt;
&lt;h3&gt;Native build&lt;/h3&gt;
&lt;p&gt;Javalin supports GraalVM. GraalVM builds are OS-native binaries, compiled
into full executable apps that can run without the JVM. This is super attractive
for Serverless and functions that needs cold-start within seconds.&lt;/p&gt;
&lt;p&gt;Here's an example from their main page:
&lt;a class="reference external" href="https://javalin.io/2018/09/27/javalin-graalvm-example.html"&gt;https://javalin.io/2018/09/27/javalin-graalvm-example.html&lt;/a&gt; and if you want
something more complete, including tests, Flyway migrations, and more, you can
take a look at this personal project I'm building:
&lt;a class="reference external" href="https://github.com/thermcampos/lin-order-java"&gt;https://github.com/thermcampos/lin-order-java&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="javalin-x-spring-boot"&gt;
&lt;h3&gt;Javalin x Spring Boot&lt;/h3&gt;
&lt;p&gt;I compared bundle size, dependencies, startup time, and JVM memory on both. The
results are very interesting.&lt;/p&gt;
&lt;p&gt;Both applications has the same added dependencies, same endpoints, and the same
functions. They have Postgres database support and Flyway migration, added
on top of the &lt;em&gt;empty&lt;/em&gt; project. For Spring Boot, I got it from the Spring
initializer page, and for Javalin, I got from the maven quickstart archetype.&lt;/p&gt;
&lt;p&gt;In terms of endpoints, both have only:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;An index &lt;strong&gt;/&lt;/strong&gt; that returns &lt;strong&gt;Hello World&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;A hello &lt;strong&gt;/hello/{name}&lt;/strong&gt; that returns &lt;strong&gt;Hello {name}&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;And here are the results.&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;Bundle size - This is the fatjar&lt;ul&gt;
&lt;li&gt;Javalin size was &lt;strong&gt;9.4 MB&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Spring Boot size was &lt;strong&gt;23 MB&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Dependencies - Considering only runtime&lt;ul&gt;
&lt;li&gt;Javalin had &lt;strong&gt;44&lt;/strong&gt; dependencies&lt;/li&gt;
&lt;li&gt;Spring Boot had &lt;strong&gt;53&lt;/strong&gt; dependencies&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Startup time&lt;ul&gt;
&lt;li&gt;Javalin took &lt;strong&gt;0.548&lt;/strong&gt; seconds&lt;/li&gt;
&lt;li&gt;Spring Boot &lt;strong&gt;5.229&lt;/strong&gt; seconds&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Memory footprint using JVM&lt;ul&gt;
&lt;li&gt;Javalin took 144320 KB, about &lt;strong&gt;140 MB&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Spring Boot took 205892, about &lt;strong&gt;201 MB&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Javalin startup screenshot&lt;/p&gt;
&lt;img alt="/attachments/javalin-startup.png" src="/attachments/javalin-startup.png" /&gt;
&lt;p&gt;Spring Boot startp screenshot&lt;/p&gt;
&lt;img alt="/attachments/spring-startup.png" src="/attachments/spring-startup.png" /&gt;
&lt;p&gt;This gives us a good perspective about frameworks. Depending of your needs,
of course, Javalin can give you a lightweight working app. Unless you need
Spring Boot's out-of-the-box ready features.&lt;/p&gt;
&lt;p&gt;That's all for today. If you have any questions, I'll be happy to answer. Reach
out by using the comment system below or any of the link in the about page.&lt;/p&gt;
&lt;p&gt;This post will get a video version on YouTube, stay tuned and keep an eye at
this channel: &lt;a class="reference external" href="https://www.youtube.com/&amp;#64;thermcampos"&gt;https://www.youtube.com/&amp;#64;thermcampos&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Thanks for reading.&lt;/p&gt;
&lt;/div&gt;
</content></entry></feed>