https://kotlinlang.org logo
#ktor
Title
# ktor
k

Kaj Koivunen

03/14/2024, 2:52 PM
How do I make the fat jar built by ktor runnable? Trying to run it only gives
Error: Could not find or load main class ktortest-all.jar
c

Casey Brooks

03/14/2024, 4:09 PM
It looks like the jar is trying to run with the artifact name as the main class. You need to specify an actual JVM class name in your
build.gradle.kts
file. For example, if your application has your
fun main()
in a file at
src/main/com/example/application.kt
, the class name will be
com.example.ApplicationKt
https://ktor.io/docs/fatjar.html#build
f

Fernando Sanchez (Perraco Labs)

03/14/2024, 4:19 PM
did you add next to your build Gradle file?
Copy code
application {
    mainClass.set("your_package.ApplicationKt")
}
where
ApplicationKt
is the file where the
main
is defined
1