Install Kotlin without using an IDE like JetBrains (IntelliJ IDEA, Android Studio, etc.)

By manoj , 30 April, 2025

To install Kotlin without using an IDE like JetBrains (IntelliJ IDEA, Android Studio, etc.), you can use the Kotlin Compiler (kotlinc) directly. Here's how to install and use Kotlin on your system:


Method 1: Install Kotlin via SDKMAN! (Recommended for Linux/macOS)

  1. Install SDKMAN! (if not already installed):

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

    Then, follow the instructions to initialize it:

    source "$HOME/.sdkman/bin/sdkman-init.sh"

  2. Install Kotlin:

    sdk install kotlin

  3. Verify Installation:

    kotlin -version


Manual Installation (Windows/macOS/Linux)

  1. Download the Kotlin Compiler:
    • Get the latest version from Kotlin Releases on GitHub.
    • Example (for v1.9.22):

      wget https://github.com/JetBrains/kotlin/releases/download/v1.9.22/kotlin-compiler-1.9.22.zip

  2. Extract the ZIP file:

    unzip kotlin-compiler-*.zip -d kotlin

  3. Add Kotlin to PATH:
    • Linux/macOS: Add the following to ~/.bashrc or ~/.zshrc:

      export PATH="$PATH:/path/to/kotlin/kotlinc/bin"

      Then reload:

      source ~/.bashrc

    • Windows: Add C:\path\to\kotlin\kotlinc\bin to your PATH in System Environment Variables.
  4. Verify Installation:

    kotlinc -version


Run Kotlin Code Without an IDE

  1. Create a Kotlin File (hello.kt):

    fun main() {
        println("Hello, Kotlin!")
    }

  2. Compile:

    kotlinc hello.kt -include-runtime -d hello.jar
    java -jar hello.jar

    • -include-runtime: Embeds the Kotlin runtime in the JAR.
    • -d: Specifies the output file.
  3. Run:

    java -jar hello.jar


Dependencies

  • Ensure you have Java (JDK 8+) installed:

    java -version

    If not, install it: