Mint

Install Kotlin on Linux Mint 20

Introduction:

Kotlin is a statically typed programming language that came into being in 2011. It is a programming language that can be used for general purposes and is also capable of working along with Java. Moreover, this programming language can work across different operating systems. As far as this particular guide is concerned, then we will try to explain to you the procedure of installing Kotlin on a Linux Mint 20 system.

Installation of Kotlin on Linux Mint 20:

For installing the Kotlin programming language on a Linux Mint 20 system, we will perform the following steps. Moreover, this installation will be followed by creating and running a sample Kotlin script as well for testing its successful installation.

Step # 1: Install Kotlin on Linux Mint 20:

First, we will install Kotlin on Linux Mint 20 by running the command given below:

$ sudo snap install kotlin --classic

The installation of the Kotlin programming language will terminate with the following message:

Step # 2: Create a Sample Kotlin File:

Now, to test our installation, we will attempt to create a sample Kotlin file with the command shown below:

$ sudo nano sample.kt

Here, you need to know that all the Kotlin files have the “.kt” extension.

Step # 3: Write a Basic Program in Kotlin:

When this Kotlin file will open up in the nano editor, we will write a basic “hello world” program in it as shown in the following image. After that, we will save and close our Kotlin script for going back to our terminal.

Step # 4: Ensure the Presence of the Kotlin Compiler on Linux Mint 20:

Now, before compiling this Kotlin script, we need to make sure that the Kotlin compiler exists on our system. For that, we will run the command shown below:

$ kotlinc

The following output will indicate the presence of the Kotlin compiler on our Linux Mint 20 system:

Step # 5: Compile the Kotlin Program:

We will simply type “:quit” and press the Enter key for exiting from the Kotlin compiler’s interface. After that, we will run the command shown below in our terminal for compiling our Kotlin script:

$ kotlinc sample.kt

Step # 6: Run the Kotlin Program:

Whenever a Kotlin script is being compiled, it is renamed by capitalizing the first alphabet of that file’s name as well as the “k” of the extension. Also, the “.” in the name is removed in the compiled file’s name. For example, the name of our Kotlin script file was “sample.kt” which after compilation became “SampleKt”. Now, we will execute this compiled script with the following command:

$ kotlin SampleKt

The output of our Kotlin script is shown in the image below:

Removal of Kotlin from Linux Mint 20:

For removing the Kotlin programming language from a Linux Mint 20 system, you need to execute the following command:

$ sudo snap remove kotlin

Conclusion:

With the help of this quick tutorial, you will be able to install Kotlin and get started with it on a Linux Mint 20 system very easily. Moreover, once you do not need this programming language any longer, then you can even remove it from your system very conveniently.

Similar Posts