How to install Kotlin Programming language in Ubuntu 22.04 LTS

Endrit Qerreti

Endrit Qerreti

In this tutorial, you will learn how to install kotlin programming language in Ubuntu 22.04.

To be able to build and run an app written in kotlin, you must have kotlin installed in your machine.

In Ubuntu 22.04, installing kotlin is very easy, and is done by using the terminal via apt package manager.

Install kotlin in Ubuntu 22.04

kotlin package is available on the default Ubuntu repositories, including : Ubuntu 22.04, Ubuntu 23.04 and Ubuntu 23.10, which means you can easily install kotlin using the terminal via apt package manager.

Step 1 - Update system

Before we install kotlin, we need to make sure the machine is updated.

First you need to check for updates by running the command below.

sudo apt update

And if you see that there are packages that needs to be upgraded, then proceed to upgrade them with.

sudo apt upgrade

Step 2 - Install kotlin

You should be able to install kotlin now.

Like we said kotlin is listed in the default repositories for Ubuntu 22.04, Ubuntu 23.04 and Ubuntu 23.10, so if you are running any of these Ubuntu versions, then you can install kotlin by running the following.

Note: Java 8 or higher version needs to be installed in your system in order to be able to run Kotlin. You can install java easily by following our tutorial.

sudo apt install kotlin

Step 3 - Check kotlin installation

kotlin should be installed in your Ubuntu machine now. Before you use kotlin to compile your kotlin code, make sure that kotlin is installed correctly.

The easiest and fastest way to see if kotlin was installed correctly, is by checking kotlin version.

To check kotlin version, simply run the command below.

kotlinc -version

And it should display kotlin version, this means kotlin was installed correctly, and you can proceed to the next step to write a kotlin app.

Step 4 - Compile with kotlin

Now that kotlin is installed in your Ubuntu machine, you should be able to use it and compile your app.

In this tutorial, we'll create a simple app written in kotlin, that will output "Hello World".

1) First, create the kotlin file project.kt using nano text editor.

sudo nano project.kt

2) Add the following code into project.kt

fun main() {
    println("Hello world!")

3) Compile project.kt

kotlinc project.kt -include-runtime -d project.jar

4) Run project.kt

java -jar project.jar

Uninstall kotlin in Ubuntu 22.04

To uninstall kotlin, simply run the following command.

sudo apt remove kotlin


In this tutorial, you learned how to install kotlin and how to compile an app with kotlin in Ubuntu 22.04.

This tutorial, applies to Ubuntu 22.04, Ubuntu 23.04 and Ubuntu 23.10.