Getting Started
You have chosen Levtus, so now let’s get you ready to start coding right away!
System Requirements
Section titled “System Requirements”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
Creating a new project
Section titled “Creating a new project”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>implementation("io.github.bernardusz:levtus-core:0.2.0")Or you can visit Maven Central to get your snippet for you specific project/dependency manager
Project Directory Structure
Section titled “Project Directory Structure”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
Getting Started with Levtus
Section titled “Getting Started with Levtus”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.
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);}Serving the Application
Section titled “Serving the Application”Run the application directly using the exec-maven-plugin:
mvn compile exec:java -Dexec.mainClass="Main"Run the application using the Gradle application plugin:
./gradlew runEnsure your build.gradle defines your entry point:
plugins { application}
application { mainClass.set("Main")}Voila 🐧 You have just created your first Levtus app. Continue to the next API documentation to keep the momentum alive! 🐧🐧🐧