Vedran
01/04/2025, 4:58 PM./gradlew build --no-daemon
and then:
java -jar build/libs/app-jvm.jar
I will get:
Error: Could not find or load main class io.ktor.server.netty.EngineMain
Caused by: java.lang.ClassNotFoundException: io.ktor.server.netty.EngineMain
Now .... I tried with relative path to Application.kt, still does not work
EDIT:
I've tried with new generated project from Ktor, it's the same, you cannot start jar from build/libsjoffrey
01/06/2025, 10:02 AMjoffrey
01/06/2025, 10:07 AM./gradlew build
(even without Amper), it will just build a jar containing your own classes. It is not a self-contained fat jar with all dependencies. You would need to pass all dependency jars on the classpath in your java
call.
Usually people either use some 3rd party Gradle plugin to create a fat jar, or the built-in Gradle Distribution plugin to create an application distribution. The distribution is a zip or directory containing lib/
with all jars, and bin/
with a couple start scripts that use the correct java command to run your application.joffrey
01/06/2025, 10:15 AM