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 https://get.sdkman.io | 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

References:
https://en.wikipedia.org/wiki/Kotlin_(programming_language)
http://kotlinlang.org/docs/tutorials/command-line.html
https://android-developers.googleblog.com/2017/05/android-announces-support-for-kotlin.html

Search within Codexpedia

Custom Search

Search the entire web

Custom Search