Step 0: Set up JDK
Kotlin requires that your JDK be set up. You can head over to Oracle's official website to download and install JDK 8.
Step 1: Get Kotlin
First we have to get the latest release of the Kotlin. Follow this link to download Kotlin's latest release. At the time of writing, the latest version was v1.3.61
. For Linux, download kotlin-native-linux-1.3.61.tar.gz
and place it in a directory of your choosing.
Step 2: Extract and Move Kotlin
I prefer to have Kotlin set up in /usr/local/bin/kotlin
. Having it there and renamed to 'kotlin'
instead of 'kotlin-native-linux-1.3.61'
makes it easy for me to update Kotlin whenever a newer release is ready. We'll get to that in a minute. For now, open your terminal and follow these steps:
# first let's extract Kotlin
$ tar zxfv kotlin-native-linux-1.3.61.tar.gz
# next we'll rename the extracted folder
$ mv kotlin-native-linux-1.3.61/ kotlin
# then we'll create a kotlin directory in /usr/local/bin (requires admin rights)
$ mkdir /usr/local/bin/kotlin
# move kotlin
$ mv kotlin /usr/local/bin/
Step 3: Add Kotlin to PATH
We have to add Kotlin to our PATH so we can access the compiler without having to write out the full path to our installation. Add the following lines to your '~/.bashrc'
file.
export KOTLIN_HOME=/usr/local/bin/kotlin
export PATH=$PATH:$KOTLIN_HOME/bin
Then make sure to run source ~/.bashrc
in order to access the Kotlin compiler in your current terminal session.
Step 4: Check Kotlin Installation
Run the following command to confirm that you can access the Kotlin compiler:
$ kotlinc -version
# should return something like => info: kotlinc-native 1.3.60
Step 5: Upgrading Kotlin
To upgrade Kotlin, delete the contents of your current installation in /usr/local/bin/kotlin
. Download and extract a more recent version of Kotlin and move the extracted content into /usr/local/bin/kotlin
(a repeat of step 2). Voila!
Top comments (0)