---
title: Javalin 101 with Kotlin & Gradle
url: https://calvin.my/posts/javalin-101-with-kotlin-gradle
published: 2024-09-04
updated: 2026-09-17
category: Development
tags:
- Javalin
- Kotlin
- Gradle
- Web
summary: This tutorial explains how to create a basic Javalin web application in IntelliJ using Kotlin and Gradle. It covers creating the project, adding Javalin, defining a simple root endpoint, and resolving the required logging dependency that otherwise prevents startup. After configuring the logger and syncing Gradle, readers can run the application and confirm that it returns a basic response through a browser or Postman.
---

# Javalin 101 with Kotlin & Gradle

If you already know Kotlin & Gradle and want to develop a simple web application, [Javalin](https://github.com/javalin/javalin) is a good option.

This article shows the steps to develop a Javalin application using IntelliJ IDE.

* * *

1. Create a new Kotlin project in IntelliJ.

2. Provide a name and select Gradle as the build system.

   ![](https://camy-pub.s3.ap-southeast-1.amazonaws.com/e168daa9-7748-4579-a10b-c37dc7881411.png)

3. Open the "build.gradle.kts" file once the project is created.

4. Add Javalin into the dependencies.

   ```kotlin
   implementation("io.javalin:javalin:6.3.0")
   ```

5. Create a new Kotlin file, with a Main class.

   ```kotlin
   import io.javalin.Javalin

   fun main(args: Array<String>) {
       val app = Javalin.create(/*config*/)
           .get("/") { it.result("Hello World") }
           .start(7777)
   }
   ```

6. Now you have a simple web application that returns a string.

7. But, when you run this code, it gives you an error - "It looks like you don't have a logger in your project". You need to add a logger for the Javalin application to launch.

   ```kotlin
   dependencies {
       // other codes
       implementation("io.javalin:javalin:6.3.0")
       implementation("org.slf4j:slf4j-simple:2.0.16")
   }
   ```

8. The easiest solution is to use slf4j-simple. Add it to the dependencies block and create a configuration in the main/resources directory.

   ![](https://camy-pub.s3.ap-southeast-1.amazonaws.com/de7c0ea2-3e47-428a-a523-5c1650a29a4a.png)

9. A sample configuration is as follows.

   ```yaml
   # see https://www.slf4j.org/apidocs/org/slf4j/simple/SimpleLogger.html
   org.slf4j.simpleLogger.defaultLogLevel=DEBUG
   org.slf4j.simpleLogger.showDateTime=true
   org.slf4j.simpleLogger.dateTimeFormat=YYYY-MM-dd HH:mm:ss.SSS
   # less jetty noise
   org.slf4j.simpleLogger.log.org.eclipse.jetty=INFO
   # more javalin noise
   org.slf4j.simpleLogger.log.io.javalin=TRACE
   ```

10. Finally do a gradle sync and run the Main class. You should see the application is launched successfully.

    ![](https://camy-pub.s3.ap-southeast-1.amazonaws.com/a9df8c3b-c1ce-4d24-844d-c4dc406e7550.png)

* * *

Try accessing the URL from your browser or the Postman tool. You should see the "Hello World" string printed.

(Browser)

![](https://camy-pub.s3.ap-southeast-1.amazonaws.com/a12c0781-1020-4ec1-a043-c03c79e465df.png)

(Postman)

![](https://camy-pub.s3.ap-southeast-1.amazonaws.com/90830998-96f6-44b8-a0df-be27102b71b0.png)
