Kotlin Environment

Start with a JDK, then add Kotlin tooling, then choose an editor that understands both Java and Kotlin well.

Install the JDK

Because Kotlin/JVM compiles to bytecode executed by the Java Virtual Machine, you need a Java Development Kit (JDK) installed first. Choose a current Long-Term Support (LTS) distribution such as JDK 17 or JDK 21 (for example, Eclipse Temurin) so Gradle and your IDE run on a well-supported runtime. Verify your installation and JAVA_HOME path from a terminal before scaffolding projects.

Tooling options

Depending on whether you are building backend services, Android apps, or quick command-line experiments, you will combine an IDE with a build tool:

  • IntelliJ IDEA: Built by JetBrains (Kotlin's creator); offers the most accurate type inference hints, refactoring, and coroutine debugging.
  • Android Studio: IntelliJ-based IDE preconfigured with Android SDKs, emulators, and Compose previews.
  • Gradle (Kotlin DSL): The standard build tool for dependency management, testing, and multi-module JVM projects.
  • kotlinc CLI: Useful for compiling single-file scripts or running quick REPL checks without a full Gradle project.

Project setup

For reproducible builds across machines and CI pipelines, initialize projects with the Gradle Wrapper (./gradlew) rather than relying on a globally installed Gradle binary. The wrapper pins the exact Gradle version in gradle/wrapper/gradle-wrapper.properties:

# Verify JDK availability first
java -version

# Scaffold a new Kotlin application with Gradle Kotlin DSL
mkdir kotlin-lab && cd kotlin-lab
gradle init --type kotlin-application --dsl kotlin

# Build and run using the pinned Gradle Wrapper
./gradlew run

Editor workflow

In IntelliJ IDEA or Android Studio, open the project's root build.gradle.kts so the IDE syncs dependencies and enables jump-to-definition across JVM libraries. If you prefer a lighter editor like VS Code, pair it with the Gradle CLI for running tests (./gradlew test) and compiling, since IDE language servers outside IntelliJ have limited refactoring support for multiplatform or complex DSLs.

Practice

Complete these setup steps to confirm your local workstation can compile and run Kotlin:

  1. Install an LTS JDK and confirm both java -version and javac -version succeed.
  2. Scaffold a Gradle Kotlin application, inspect app/build.gradle.kts, and execute ./gradlew run.
  3. Run ./gradlew test to verify the default unit test runner passes cleanly.