Skip to the content.

Kotlin CLI


Compiler targeting the JVM

Compiling Hello.kt into a jar (will include manifest)

kotlinc-jvm Hello.kt -d Hello.jar


Run a kotlin program.

Run a compiled jar on the JVM

kotlin Hello.jar

REPL - kotlinc-jvm

When the compiler is called without any arguments it opens the REPL.

In the REPL an external file can be loaded using :load <filename>

:load TestLoad.kt
main(arrayOf("elem1", "elem2")) // res1: kotlin.Int = 2
println("length of array is ${main(arrayOf("elem1", "elem2"))}")