Kotlin requires that your JDK be set up. You can head over to Oracle's official website to download and install JDK 8.
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.
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/
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
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.
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
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!