Language
日本語
English

Caution

JavaScript is disabled in your browser.
This site uses JavaScript for features such as search.
For the best experience, please enable JavaScript before browsing this site.

  1. Home
  2. Kotlin Dictionary
  3. [Setup] Kotlin Development Environment

[Setup] Kotlin Development Environment

This page walks you through setting up a Kotlin development environment. Since Kotlin runs on the JVM (Java Virtual Machine), you first need to install the JDK.

Installing the JDK

A JDK (Java Development Kit) is required to compile and run Kotlin programs.

  1. Download the JDK from Adoptium or Oracle.
  2. After installation, verify with the following command.
java -version

If version information is displayed, the JDK installation is complete.

Installing the Kotlin Compiler

There are several ways to install the Kotlin compiler.

MethodDescription
SDKMANA version management tool for macOS / Linux. This is the recommended method.
HomebrewOn macOS, you can install via Homebrew.
Manual installDownload directly from kotlinlang.org.

To install with SDKMAN:

sdk install kotlin

To install with Homebrew:

brew install kotlin

After installation, verify with the following command.

kotlinc -version

Compiling and Running

1. Create the source file

Use a text editor to create a file named hello.kt with the following content.

fun main() {
    println("Hello, World!")
    println("The Kotlin environment is set up successfully.")
}

2. Compile

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

-include-runtime bundles the Kotlin runtime into the JAR, producing a self-contained file that can be run with just Java.

3. Run

java -jar hello.jar

If Hello, World! and The Kotlin environment is set up successfully. are displayed, you're all set.

Try in Your Browser (Kotlin Playground)

If you want to try Kotlin without setting up a local environment, Kotlin Playground is a great option. You can type code in your browser and see the results immediately.

A good approach is to experiment with the syntax in Playground during the early stages of learning, then set up a local environment when you are ready for more serious development.

IDE Development

ToolDescription
IntelliJ IDEAThe IDE from JetBrains, the creators of Kotlin. Offers the best Kotlin development experience. The Community edition is free.
Android StudioAn IDE for Android app development. Based on IntelliJ IDEA with native Kotlin support.
Visual Studio CodeInstalling the Kotlin extension adds syntax highlighting and code completion.

If the Command Is Not Found

If your terminal displays kotlinc: command not found, the PATH may not be configured correctly. Follow the steps below to check and fix the issue.

1. Find the command location

Check where the command is located.

which kotlinc
which kotlin

If not found, check common installation locations.

ls /opt/homebrew/bin/kotlinc
ls ~/.sdkman/candidates/kotlin/current/bin/kotlinc

2. Check which shell you are using

echo $SHELL

If /bin/zsh is shown, edit ~/.zshrc; if /bin/bash is shown, edit ~/.bashrc.

3. Add to PATH

Once you know the command location, add the PATH to your shell configuration file.

If installed with Homebrew (macOS zsh):

echo 'export PATH="/opt/homebrew/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc

If installed with SDKMAN (macOS zsh):

echo 'export PATH="$HOME/.sdkman/candidates/kotlin/current/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc

For Linux (bash):

echo 'export PATH="$HOME/.sdkman/candidates/kotlin/current/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc

If you are using SDKMAN

If Kotlin installed via SDKMAN is not found, the shell initialization may be missing. Make sure the following is present in your shell configuration file.

SDKMAN initialization script:

export SDKMAN_DIR="$HOME/.sdkman"
[[ -s "$HOME/.sdkman/bin/sdkman-init.sh" ]] && source "$HOME/.sdkman/bin/sdkman-init.sh"

Also check the JDK PATH

Since Kotlin runs on the JVM, the java command must also be available. If java -version returns an error, configure the JDK PATH as well.

For Windows, go to "Advanced System Settings" → "Environment Variables" → "Path" and add paths for both Kotlin and the JDK.

If you find any errors or copyright issues, please .