Hullo! I'm trying to make use of the `javax.script...
# getting-started
h
Hullo! I'm trying to make use of the
javax.script
support that was introduced in Kotlin 1.1, however the first line always throws a
NullPointerException
.
Copy code
val engine = ScriptEngineManager().getEngineByExtension("kts")!!
engine.eval("val x = 3")
println(engine.eval("x + 2"))  // Prints out 5
I'm extremely new to this language and its tooling, is there something obvious I'm missing? I was under the impression that it would sort of just "come with" the language but I wouldn't be surprised at all if I need to install a dependency or two. My google skills have been failing me unfortunately.
p
I have no hands-on experience but from what I have found it seems like you may indeed be missing a dependency. If you are using gradle, this might be helpful: https://github.com/JetBrains/kotlin/blob/master/libraries/examples/kotlin-jsr223-local-example/build.gradle.kts
h
I'll give it try, thanks 🙂