To get started with Kotlin, it’s important to have the Kotlin runtime and compiler installed. Installing these can be done in numerous ways:
- Install Kotlin from GitHub
- Install Kotlin using Brew
- Install Kotlin using SDKMan
- Install Kotlin using IntelliJ
Install Kotlin from GitHub
To make sure you are using the latest Kotlin version, you can install Kotlin by downloading the compiler from the GitHub releases page.
Follow the steps below to install Kotlin’s compiler:
- Go to the Kotlin releases page on GitHub
- Download the Kotlin compiler zip file.
nativecompiler is only needed when developing native applications for Mac, Windows, etc, so we can skip that for now.)
- Unzip the kotlin-compiler-<version>.zip file and add the path to your PATH variable. For example, if you’ve extracted the zip file to
~/Downloads/kotlinc, add this to your path (most likely in your
~/.profilefile, by adding the line:
- Reload your terminal, and type
kotlin -versionto see if Kotlin has been installed correctly.
Install Kotlin using Brew
Brew is an easy to use package manager for Mac OS. It can be used to install numerous packages, including Kotlin.
To install the latest version of Kotlin using Brew, all is needed is to type the following command:
brew install kotlin
Install Kotlin using SDKMan
SDKMan is a tool for managing versions of multiple Software Development Kits on most Unix based systems, such as Linux and MacOS.
Installing Kotlin using SDKMan is quite easy. If SDKMan hasn’t been installed yet, you can do so with the following command:
curl -s "https://get.sdkman.io" | bash
After that, typing:
sdk install kotlin
Will install the latest version of Kotlin.
If you need to install an older version of Kotlin, SDKMan can also do that, using the following command:
sdk install kotlin 1.3.60
Install Kotlin using IntelliJ
Both the IntelliJ Ultimate (Paid) and the IntelliJ Community (Free) come with support for Kotlin built in to the product. This won’t install Kotlin into a terminal, but it will allow you to get started using Kotlin right from the IDE, by either creating a new Kotlin project or using the Kotlin REPL or Kotlin Scratch files.