Install, compile and run Kotlin from command line

Prerequsite: Kotlin runs on jvm, which means java is required to run it.

Install sdkman from command line if it is not installed yet.

curl -s | bash

Install Lotlin using the command sdk from the command line.

sdk install kotlin

Create a new file hello.kt

fun main(args: Array<String>) {
    println("Hello World!")

Compile the kotlin code using the kotlin compiler.

kotlinc hello.kt -include-runtime -d hello.jar

Run the kotlin code on jvm using the java command.

java -jar hello.jar


Search within Codexpedia

Custom Search

Search the entire web

Custom Search