Skip to content

Getting Started

You have chosen Levtus, so now let’s get you ready to start coding right away!

Levtus is build for the modern JVM, so you will need to have Java 25 or higher installed on your system:

  • Java 25 or higher (JDK)
  • Maven or Gradle build tool

Create your new blank Java project using your favorite IDE or build tool. Then, add Levtus as a dependency to your project.

Paste the code below into your pom.xml or build.gradle file to add Levtus as a dependency to your project.

<dependency>
<groupId>io.github.bernardusz</groupId>
<artifactId>levtus-core</artifactId>
<version>0.2.0</version>
</dependency>

Or you can visit Maven Central to get your snippet for you specific project/dependency manager

Your project directory structure should look like this:

  • pom.xml/build.gradle
  • Directorypublic
    • index.html
  • Directorysrc
    • Directorymain
      • Directoryjava
        • Main.java
      • Directorytest
        • Directoryjava
          • MainTest.java

Or it can change depending on your reverse domain name, using Kotlin or other JVM languages, but the important part is to have a Main file in your project

Paste the following snippets below to get started with your first Levtus application. You can copy and paste the code into your Main.java file.

Main.java
import io.github.bernardusz.levtus.Levtus;
void main() {
Levtus app = Levtus.create();
// Middleware support
app.use((ctx, next) -> {
System.out.println("Request received: " + ctx.req().path());
next.run();
});
// Simple GET route
app.get("/hello", ctx -> {
ctx.text("Hello from the Levtus Engine!");
});
// Dynamic routing with path params
app.get("/user/{id}", ctx -> {
String userId = ctx.param("id");
ctx.json("{"id": "" + userId + ""}");
});
// Secure static file rendering
app.get("/", ctx -> {
ctx.render("index.html");
});
app.listen(8080);
}

Run the application directly using the exec-maven-plugin:

Terminal window
mvn compile exec:java -Dexec.mainClass="Main"

Voila 🐧 You have just created your first Levtus app. Continue to the next API documentation to keep the momentum alive! 🐧🐧🐧