Kotlin as embedded scripting engine

I want to use Kotlin as embedded scripting engine in Java application (Java 7, stand alone or inside tomcat/jetty).

Any suggestions ?

Thanks in advance :slight_smile:

1 Like

Try looking here: https://github.com/orangy/komplex/blob/master/launcher/src/ScriptingHost.kt It's a little bit outdated, but can give you general idea about how to interact with compiler, how to compile and execute a .kts script.

I'm also looking for a way to compile Kotlin scripts at runtime.

KotlinToJVMBytecodeCompiler.compileScript() seems to be a good starting point. Unfortunately there is not much documentation in the code. I’ll try to wrestle through the code to get something to run with M12.

1 Like