Home

Kotlin From CLI

Resources

  1. Kotlin compile and run from CLI

Hello World from the CLI

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

Compiling

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

Running

java -jar hello.jar

Running a task

Find Kotlin path with which kotlin.

export PATH=$PATH:/path/from/which/kotlin function kotlinr() { echo Compiling, please wait... kotlinc $1 -include-runtime -d out.jar java -jar out.jar }

After sourcing, you could now run kotlinr hello.kt.

Repository

https://github.com/okeeffed/developer-notes-nextjs/content/kotlin/kotlin-from-cli

Sections


Related