Installation & Hello World!

Installation & Hello World!

Hello there👋, welcome back! We shall continue from our last post (Introduction to Kotlin.) I want to emphasize that if you are new to programming, sit tight! You might kill two birds with one stone.

So there is no need for downloading android IDEs like Intellij or Android Studio because we shall use the repl .

Kotlin code compiles down to Java bytecode which is then executed by the JVM. So you need to have at least the Java compiler and Java runtime.

A manual install certainly works, but some developers prefer to use package managers like SDKMAN which is originally designed for Unix-based shells. A package manager automates the installation process, and some of them allow you to maintain multiple versions of a particular compiler.

Just like installing Python, Kotlin is quite similar! Head over to the Kotlin Official Github page and download the command line version since we shall be using that in this tutorial.


🔼 Install JDK from here
🔼 Run & Install the JDK (Admin rights required)
🔼 Open this Kotlin Github release page
🔼 Scroll down to the assets section, download the latest version of the compiler.
🔼 You can grab kotlinc
🔼 Unzip the file in a folder from where we have access to write.
🔼 Recommended creating a new Kotlin folder in the root user folder.
🔼 Update the PATH variable with the bin location of Kotlin’s compiler. For example D:\kotlinc\bin

Let me know in the comment section if you need more help in updating the path variable otherwise, you can stack overflow, google or check out this tutorial

That's It!

To check whether the Kotlin compiler has been properly installed, we can run in the command line, the command ‘kotlinc’ to get a ‘Welcome to Kotlin’ message as follows.

rra.jpg The above will not work if you do not have the JDK installed yet.

Also, let me know in the comment section if you still need help with installation. Be sure to check out the official docs here for more help.


316867.jpg If You want to try out Kotlin without a local installation or run it on a machine that does not support it (for example, a Chromebook). Use the Kotlin Playground, an online sandbox for exploring Kotlin.

Hello World!

To get the famous hello world in the terminal, create a simple file in Kotlin that displays "Hello, World!". You can use your favourite editor or notepad. Call it hello.kt with the following lines:

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

Hold a sec, what's happening here🤷?

◻The fun is for creating for functions in Kotlin
◻The main is by convention the entry point for an application.
◻The { } are required for code block execution.
◻The kt is the file extension for kotlin files.

Compile the hello world app using the Kotlin compiler:
Now in the terminal, change the directory to where your kt file is.

Write this, do not copy😊!

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

Check the directory to see the newly compiled java bytecode with the same name e.g hello.jar


I am assuming a Windows System here!

Run the created java file like this:

java -jar hello.jar

This should be the expected output!


Remember you can use Kotlin for

📍 Android
📍 Web Front end
📍 Mobile Multiplatform
📍 Backend
📍 CS 101 Education

Note: This tutorial is about learning Kotlin as a programming language, not android development! However, at the end of the series, I will make small introductions to the basic android setup.

See you in the next article😊 >> Follow me on Twitter

Ronnie Atuhaire 😎