Skip to content
kotlin: command not found

kotlin: command not found

DodaTech 2 min read

The “kotlin: command not found” error means your shell cannot locate the kotlin or kotlinc binary needed to compile and run Kotlin code.

What It Means

Kotlin provides two command-line tools: kotlin for running .kotlin scripts and compiled classes, and kotlinc for compiling .kt source files into JVM bytecode. When neither binary is found in any directory listed in your PATH variable, the shell returns “command not found.”

Why It Happens

  • The Kotlin compiler is not installed on your system.
  • SDKMAN or a package manager installed Kotlin but did not update your PATH.
  • You installed Kotlin via IntelliJ IDEA but didn’t install the standalone compiler.
  • The Kotlin binary directory (e.g., ~/.sdkman/candidates/kotlin/current/bin) is not in your PATH.
  • You are using an old terminal session that hasn’t reloaded after installation.

How to Fix It

1. Install Kotlin via SDKMAN (recommended)

SDKMAN installs Kotlin and updates PATH automatically:

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

# Install Kotlin
sdk install kotlin

# Verify
kotlin -version
# Output: Kotlin version 2.0.0-release-...

2. Install Kotlin via package manager

macOS (Homebrew):

brew update
brew install kotlin

Ubuntu/Debian (Snap):

sudo snap install kotlin --classic

3. Install the standalone compiler manually

# Download the latest compiler release
curl -L -o kotlin-compiler.zip https://github.com/JetBrains/kotlin/releases/download/v2.0.0/kotlin-compiler-2.0.0.zip
unzip kotlin-compiler.zip
sudo mv kotlinc /usr/local/kotlin

4. Add Kotlin to your PATH

If Kotlin is installed but not found, add it to your shell config:

# Add to ~/.bashrc or ~/.zshrc
export PATH="$PATH:$HOME/.sdkman/candidates/kotlin/current/bin"
source ~/.bashrc

5. Verify the installation

kotlin -version
# Expected: Kotlin version 2.0.0 (JRE 17+)
Do I need the full JDK to run Kotlin?
Yes — Kotlin compiles to JVM bytecode. Install JDK 17 or later (java -version to check). Kotlin also supports native and JS targets via kotlin-native and kotlin-js.
What’s the difference between kotlin and kotlinc?
kotlinc compiles .kt files into .class files (JVM bytecode). kotlin runs Kotlin scripts (.kts) and launches compiled programs. Both are included in the Kotlin compiler distribution.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro