Hello! I'm working on a compose multiplatform proj...
# ktor
j
Hello! I'm working on a compose multiplatform project that has a ktor server module, but I can't seem to align JVM versions correctly. Using JDK 20 to run Gradle, but I wish to target JDK 11 and run in docker. 🧵 ...
My build.gradle.kts:
Copy code
import org.jetbrains.kotlin.gradle.dsl.JvmTarget

plugins {
    alias(libs.plugins.kotlinJvm)
    alias(libs.plugins.ktor)
    application
}

group = "com.example"
version = "1.0.0"

java {
    sourceCompatibility = JavaVersion.VERSION_11
    targetCompatibility = JavaVersion.VERSION_11
}

kotlin {
    compilerOptions.jvmTarget.set(JvmTarget.JVM_11)
}

ktor {
    docker.jreVersion.set(JavaVersion.VERSION_11)
}

application {
    mainClass.set("com.example.ApplicationKt")
    applicationDefaultJvmArgs = listOf("-Dio.ktor.development=${extra["development"] ?: "false"}")
}

dependencies {
    implementation(projects.shared)
    implementation(libs.logback)
    implementation(libs.ktor.server.core)
    implementation(libs.ktor.server.netty)
    testImplementation(libs.ktor.server.tests)
    testImplementation(libs.kotlin.test.junit)
}
and still somehow, when running:
./gradlew runDocker
It starts, but the first request leads to:
Copy code
java.lang.UnsupportedClassVersionError: Greeting has been compiled by a more recent version of the Java Runtime (class file version 64.0), this version of the Java Runtime only recognizes class file versions up to 55.0
Are the options i set correct? And are there any I missed?
a
Can you try setting the JVM toolchain version?
Copy code
kotlin {
    jvmToolchain(11)
}
j
I was hoping to use my local JDK, but target 11, rather than using a toolchain
a
This option sets the exact version of the Java language that the toolchain is required to support.
j
oh interesting. i thought it would try to download a new JDK altogether
trying this now. thanks!