How to install Kotlin

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

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.
    (The native compiler 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 ~/.profile file, by adding the line: export PATH=$PATH:~/Downloads/kotlinc/bin
  • Reload your terminal, and type kotlin -version to 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.

Creating a new Kotlin project with IntelliJ

Leave a Reply

Your email address will not be published. Required fields are marked *