Kotlin Development Environment

Kotlin Development Environment

1. Install Java Development Kit (JDK)
- Download and install Java 8 or newer from Adoptium or Oracle.
- Verify installation:

java -version

2. Install Kotlin Compiler (Optional)
- Download standalone compiler from https://kotlinlang.org/docs/command-line.html
- Unzip and add bin/ directory to your system PATH.
- Verify installation:

kotlinc -version

IDE Setup

3. IntelliJ IDEA
- Download IntelliJ IDEA Community or Ultimate from JetBrains.
- On first launch, install the Kotlin plugin if not bundled.
- Create a new Kotlin/JVM project:
  • Select New → Project…
  • Choose Kotlin → JVM | IDEA
  • Configure JDK and finish.

4. Android Studio (for Android development)
- Android Studio supports Kotlin out of the box.
- Enable Kotlin support:
  • File → New → New Project → Kotlin templates.
  • Or add Kotlin plugin via Settings → Plugins → Kotlin.

Build Tools

5. Gradle (Kotlin DSL)
- Add to build.gradle.kts in project root:

plugins {
    kotlin("jvm") version "1.9.0"
    application
}

- Add repositories and dependencies:
repositories {
    mavenCentral()
}
dependencies {
    implementation(kotlin("stdlib"))
}
application {
    mainClass.set("MainKt")
}

- Run build and application:
./gradlew build
./gradlew run

6. Maven
- Add Kotlin plugin and stdlib in pom.xml:

<dependencies>
  <dependency>
    <groupId>org.jetbrains.kotlin</groupId>
    <artifactId>kotlin-stdlib</artifactId>
    <version>1.9.0</version>
  </dependency>
</dependencies>
<build>
  <plugins>
    <plugin>
      <groupId>org.jetbrains.kotlin</groupId>
      <artifactId>kotlin-maven-plugin</artifactId>
      <version>1.9.0</version>
      <executions>
        <execution>
          <id>compile</id>
          <goals><goal>compile</goal></goals>
        </execution>
      </executions>
    </plugin>
  </plugins>
</build>

Alternative Installers

7. SDKMAN! (Unix-like systems)
- Install SDKMAN!:

curl -s "https://get.sdkman.io" | bash
source "$HOME/.sdkman/bin/sdkman-init.sh"

- Install Kotlin:
sdk install kotlin

Command-Line & REPL

8. Kotlin REPL
- Launch interactive shell:

kotlinc-jvm

- Try expressions and test snippets.

9. Compile & Run Single File
- Compile:
kotlinc Hello.kt -include-runtime -d Hello.jar

- Run:
java -jar Hello.jar

Previous: Kotlin Introduction | Next: Your First Kotlin Program

<
>