Kotlin is a programming language that can be used for general purposes and is also capable of working along with Java. It was developed by JetBrains. Kotlin can be used to build front-end, server-side, and Android applications.
Here at LinuxAPT, as part of our Server Management Services, we regularly help our Customers to perform related Java queries.
In this context, we shall look into the procedure of installing Kotlin on a Linux Mint 20 system.
1. Perform System Update
It's important to make sure your system is up to date by running the following apt commands in the terminal:
$ sudo apt update
2. Install Kotlin Programming Language on the system
i. Install Kotlin using Snap.
Run the following commands to install Snap packages:
$ sudo rm /etc/apt/preferences.d/nosnap.pref
$ sudo apt update
$ sudo apt install snapd
To install Kotlin, simply use the following command:
$ sudo snap install kotlin --classic
ii. Install Kotlin using SDKMAN.
To install the SDKMAN tool run the following commands in your terminal:
$ curl -s "https://get.sdkman.io" | bash
Next, you’ll need to source the shell environment to activate:
$ source ~/.sdkman/bin/sdkman-init.sh
Then, open your terminal and install Kotlin with sdk command:
$ sdk install kotlin
Check Kotlin version installed:
$ kotlin -version
Now we create a simple application in Kotlin that displays "Hello, Linux user!" message:
tee hello-linux-user.kt <<EOF
fun main() {
println("Hello, Linux User!")
}
EOF
Kotlin programs need to be compiled using the Kotlin compiler before execution:
$ kotlinc hello-linux-user.kt -include-runtime -d hello-linux-user.jar
This generated .jar application which you can run with:
$ java -jar hello-linux-user.jar
Hello, Linux User!
To remove the Kotlin programming language from a Linux Mint 20 system, you need to execute the following command:
$ sudo snap remove kotlin
This article covers the complete procedure to install Kotlin and get started with it on a Linux Mint 20 system. In fact, Kotlin is an elegant, highly concise, fluent, and expressive statically typed multi-paradigm language that compiles down to both Java bytecode and JavaScript.