kotlinc, the standalone command-line compiler, compiles a .kt file directly into a runnable .jar — fine for small standalone examples, but real projects use Gradle with the Kotlin Gradle plugin (or Maven, less commonly) to manage dependencies, multi-file compilation, and packaging. IntelliJ IDEA, built by the same company that makes Kotlin, offers the most complete IDE experience, though Android Studio (itself based on IntelliJ) is the standard choice for Android development specifically.
Compiling directly with kotlinc
-include-runtime bundles the Kotlin standard library into the output jar, so it runs anywhere a JVM is installed, without needing Kotlin itself present on the target machine.
$ kotlinc hello.kt -include-runtime -d hello.jar
$ java -jar hello.jar
Hello, World!Gradle: the standard for real projects
build.gradle.kts (Kotlin-scripted Gradle, now the common default) declares the Kotlin plugin and dependencies; ./gradlew build compiles, tests, and packages the whole project in one command.
plugins {
kotlin("jvm") version "2.4.0"
}
dependencies {
testImplementation(kotlin("test"))
}$ ./gradlew buildKotlin scripting: .kts files for quick scripts
A .kts file runs directly as a script without a formal project or build step — genuinely useful for quick automation tasks, similar in spirit to a Python or shell script.
$ kotlinc -script myscript.kts