When you’re done with this tutorial, your build.gradle
file
should look like this:
group 'io.javalin' // your group id
version '1.0-SNAPSHOT'
apply plugin: 'java'
sourceCompatibility = 11
repositories {
mavenCentral()
}
dependencies {
implementation 'io.javalin:javalin:6.4.0'
}
Step by step instructions
File
->
New
->
Project
- Select
Gradle
thenJava
(orKotlin
), clickNext
- Enter
groupId
andartifactId
, clickNext
- Check
Use auto-import
, clickNext
Open the newly generated build.gradle
file and add the gradle-dependency
implementation 'io.javalin:javalin:6.4.0'
to the dependencies {}
scope.
See the full build.gradle
example above if you’re not sure where to put it.
Finally, create a file src/main/java/HelloWorld.java
or src/main/kotlin/HelloWorld.kt
and paste the Hello World example:
- Java
- Kotlin
import io.javalin.Javalin;
public class HelloWorld {
public static void main(String[] args) {
var app = Javalin.create(/*config*/)
.get("/", ctx -> ctx.result("Hello World"))
.start(7070);
}
}
import io.javalin.Javalin
fun main() {
val app = Javalin.create(/*config*/)
.get("/") { ctx -> ctx.result("Hello World") }
.start(7070)
}
Now everything is ready for you to start programming. Enjoy!