Skip to main content

Installation and Setup

Trushi Jasani
EditReport

Installation and Setup

Prerequisitesโ€‹

Before installing Kotlin, make sure you have the following:

  • Java Development Kit (JDK) โ€“ Kotlin runs on the JVM, so JDK 8 or higher is required.
  • Internet connection โ€“ To download the necessary tools.

Step 1: Install JDKโ€‹

Download and install JDK from the official Oracle or OpenJDK website.

Check if JDK is installed:

java -version

Expected output:

java version "17.0.x" ...

Step 2: Install Kotlinโ€‹

Option A: Using SDKMAN (Linux/macOS)โ€‹

# Install SDKMAN
curl -s "https://get.sdkman.io" | bash

# Install Kotlin
sdk install kotlin

Option B: Using Homebrew (macOS)โ€‹

brew install kotlin

Option C: Using Snap (Ubuntu/Linux)โ€‹

sudo snap install kotlin --classic

Option D: Manual Installation (Windows/All Platforms)โ€‹

  1. Download the Kotlin compiler from kotlinlang.org.
  2. Extract the ZIP archive.
  3. Add the bin folder to your system PATH.

Verify installation:

kotlinc -version

Expected output:

kotlinc-jvm 1.9.x (JRE 17.x.x)

Step 3: Set Up an IDEโ€‹

  1. Download IntelliJ IDEA from jetbrains.com/idea.
  2. The Community Edition is free and fully supports Kotlin.
  3. Kotlin plugin is bundled by default โ€” no additional installation needed.

Android Studioโ€‹

  1. Download from developer.android.com/studio.
  2. Kotlin is pre-installed and ready for Android development.

Visual Studio Codeโ€‹

  1. Install VS Code from code.visualstudio.com.
  2. Install the Kotlin extension from the Extensions Marketplace.

Step 4: Create Your First Kotlin Projectโ€‹

In IntelliJ IDEAโ€‹

  1. Open IntelliJ IDEA.
  2. Click New Project.
  3. Select Kotlin from the left panel.
  4. Choose JVM | IDEA as the project template.
  5. Name your project and click Create.

Using Command Lineโ€‹

# Create a file named hello.kt
echo 'fun main() { println("Hello, Kotlin!") }' > hello.kt

# Compile the file
kotlinc hello.kt -include-runtime -d hello.jar

# Run the compiled JAR
java -jar hello.jar

Step 5: Online Playground (No Installation Required)โ€‹

You can try Kotlin instantly in the browser using the official playground:

๐Ÿ”— play.kotlinlang.org

Project Structure Overviewโ€‹

A typical Kotlin project looks like this:

MyProject/
โ”œโ”€โ”€ src/
โ”‚ โ””โ”€โ”€ main/
โ”‚ โ””โ”€โ”€ kotlin/
โ”‚ โ””โ”€โ”€ Main.kt
โ”œโ”€โ”€ build.gradle.kts
โ””โ”€โ”€ settings.gradle.kts

Summaryโ€‹

MethodPlatformDifficulty
IntelliJ IDEAAllEasy
Android StudioAndroid/AllEasy
SDKMANLinux/macOSEasy
HomebrewmacOSEasy
Manual ZIPWindows/AllMedium
Online IDEBrowserEasiest

You're now ready to write your first Kotlin program!

Telemetry Integration

Completed working through this block? Sync progress to workspace.