Adam. R

How to install Kotlin on Ubuntu!

Created September 25, 2021

What is Kotlin?

Kotlin is a cross-platform, statically typed, general-purpose programming language with type inference. Kotlin is designed to interoperate fully with Java, and the JVM version of Kotlin's standard library depends on the Java Class Library, but type inference allows its syntax to be more concise


Installation

To being, install desired Java version. For example in this case we will go with Java openjdk-11-jdk:

sudo apt install openjdk-11-jdk

Next step is to install Kotlin:

sudo snap install --classic kotlin

Use any text editor and create a file called hello.kt with the following content:

fun main() {
    println("Hello World!")
}

Compile the Kotlin source code:

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

Run the actual Kotlin program:

java -jar hello.jar

The output will show the following:

Hello World!

That’s it, you have successfully installed Kotlin on your Ubuntu Server and you can start using it!

If you found this usful then please comment and follow me! Also check out my website where I also post everything from here