Write the simplest Kotlin file, and name it Main.kt
:
fun main(args: Array<String>) {
println("Hello world!")
}
Then compile the Kotlin file with kotlinc
, which runs the Kotlin compiler
❯ kotlinc Main.kt
Then run the generated MainKt.class
bytecode with
❯ java -cp ~/.sdkman/candidates/kotlin/current/lib/kotlin-stdlib.jar:. MainKt
(where ~/.sdkman/candidates/kotlin/current/lib/
is my actual path to the Kotlin lib
folder).
And you'll get:
Hello world!