I can't seem to import java dependencies in kotlin...
# scripting
p
I can't seem to import java dependencies in kotlin jvm scripts ? Neither with jsr223 or script host stuff
Copy code
import java.io.File
import javax.imageio.ImageIO
import java.awt.image.BufferedImage
These imports for example all seem problematic Scripting Host says
Copy code
Using JDK home inferred from java.home: /usr/lib/jvm/liberica21-lite
Using JVM IR backend
Using JVM IR backend
Loading modules: [melijn, java.base]
Loading modules: [java.base]
Unresolved reference: imageio
Unresolved reference: awt
JSR223 says
Copy code
error: unresolved reference: java
import java.awt.image.BufferedImage
       ^
error: unresolved reference: java
import java.io.File
       ^
error: unresolved reference: imageio
import javax.imageio.ImageIO
             ^
I'm using java inside my application so .. idk what its on about and adding compiler flags such as -Xadd-modules=ALL-MODULE-PATH to script host did not help with this Relevant script host code here: https://github.com/Melijn/melijn-bot/tree/master/bot/src/main/kotlin/me/melijn/bot/utils/script
i
We definitely had a test using
java.io.File
just fine. Do you have somewhat tricky environment that may prevent the host to extract classpath jars from the current classloader? Because you seems to be using the default approach to dependencies:
Copy code
jvm {
    dependenciesFromCurrentContext(wholeClasspath = true)
}
so the host attempts to extract CP from the classloader. You may want to try to specify the explicit classpath instead,