Question

I'm using IntelliJ IDEA Scala Worksheet. (Scala 2.11.2)

I'm trying to get ScriptEngine for Scala.

val e = (new ScriptEngineManager()).getEngineByName("scala")

But I get null:

e: javax.script.ScriptEngine = null

How can I get Scala ScriptEngine in Scala Worksheet?

Was it helpful?

Solution

Possibly there is a bug in IDEA Scala plugin. In order to make it work, first of all, you need to add scala-compiler library to Dependencies, since the SPI is in scala-compiler.jar. Secondly, uncheck "Run worksheet in the compiler process" in IDEA Preferences. I guess scala-compiler.jar is not in the classpath when external compiler is started.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top