Kotlin 2 cheatsheet

Kotlin 2: Tooling

4 common Kotlin 2 tasks.

Check the compiler version

Print the Kotlin compiler version.

kotlinc -version

Compile and run a file

Compile to a jar and run it with the Kotlin runtime included.

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

Run a script

Run a Kotlin script file (.kts).

kotlin script.main.kts

Build and test with Gradle

Build, run the tests and run the application in a Gradle project.

./gradlew build
./gradlew test
./gradlew run

Was this page helpful?