Kotlin runs on the JVM, so it needs a JDK plus the Kotlin compiler. This guide covers running, debugging and building Kotlin in VS Code.

Install the JDK and Kotlin

  • JDK first: install a current LTS JDK (adoptium.net) and confirm java -version.
  • Kotlin compiler: brew install kotlin (macOS), SDKMAN (sdk install kotlin) on macOS/Linux, or download from the Kotlin GitHub releases on Windows.

Verify: kotlinc -version

VS Code

Install the Kotlin language extension for syntax highlighting and basic IntelliSense. (For large Android/Kotlin projects many developers use IntelliJ IDEA, but VS Code works well for learning and small tools.)

Write and run

Create Main.kt:

fun main() {
    val name = "Ada"
    println("Hello, $name!")
}

Run it directly with the compiler's script runner:

kotlinc Main.kt -include-runtime -d main.jar
java -jar main.jar

Debug it

Run on the JVM with debug symbols and attach VS Code's Java debugger, or use a Gradle project for full breakpoint support. Set breakpoints in the gutter and step as you would with Java.

Build with Gradle

Real Kotlin projects use Gradle:

gradle init --type kotlin-application
gradle run
gradle build      # produces a runnable JAR in build/libs/

Gradle handles dependencies, compilation and packaging, and is the standard build tool across the Kotlin and Android ecosystems.