I'm using Windows 10 with JDK9 installed, though my project is using JDK 8 still. My main function is in src/main/kotlin/web/Server.kt relative to the working directory. The Server.kt file is
package web
import io.ktor.application.Application
import io.ktor.server.engine.embeddedServer
import io.ktor.server.netty.Netty
val port: Int = 8080
fun main(args: Array<String>) {
embeddedServer(Netty, port,
watchPaths = listOf("web"),
module = Application::main
).start(wait = true)
}
I have a Gradle task runServer which I call from a terminal, defined in my build.gradle by
task runServer(type: JavaExec) {
classpath = sourceSets.main.runtimeClasspath
println classpath.asPath
main = 'web.ServerKt'
}
If I call this task, hot reload will not work even though I configured it :
INFO ktor.application - No ktor.deployment.watch patterns match classpath entries, automatic reload is not active
For information, the previous line is
DEBUG ktor.application - Class Loader: jdk.internal.loader.ClassLoaders$AppClassLoader@4f8e5cde: []
It seems that no URLClassLoader is found in your ClassLoader chain. Let me check if I can reproduce it in windows and find a workaround
BTW, tried this: https://stackoverflow.com/questions/46519092/how-to-get-all-jars-loaded-by-a-java-application-in-java9
But doesn't work either because security issues. It seems that there is no standard non-hacky way for getting the class loader URLs in Java9.
So I think your best bet right now if you want to use the watch feature, is to install the JDK8 and use it.
Going to update the documentation noticing this.
Yeah after some testing I was also suspecting the watch feature would just not work using JDK 9.0 due to how ClassLoaders were handled. Seems like support for that platform isn't quite ready yet.
Guess I'll just revert to 8 then, thanks for everything !
Please refer to #321 for JDK9 support
Most helpful comment
Please refer to #321 for JDK9 support