Getting started with Kotlin Native

Kotlin's one of the most attractive feature is Kotlin-Native.

What's Kotlin-Native ?
Ok. Kotlin-Native is a feature in which you will be able to run kotlin application without JVM. Cool ;)

To get kotlin native support you have to install kotlin native compiler.

Kotlin-Native complier repository : https://github.com/JetBrains/kotlin-native.
First clone it in your PC. Then move to kotlin-native folder. In this folder execute,

./gradlew dependencies:update

It will install all dependencies required for kotlin native.

Then execute,
./gradlew dist && ./gradlew cross_dist

It will build binaries.
Binaries will appear in kotlin-native/dist/bin/ directory.

Now open terminal & nano Hello.kt
In Hello.kt paste the below code.

fun main(args: Array<String>) {
    println("Hello World")
}

Save & Close it.

Its time to compile. Compile with
kotlinc-native Hello.kt -o Hello

It will generate a Hello.kexe & Hello.kt.bc. Hello.kexe is platform base executable.

Give Hello.kexe executable permission by
chmod +x Hello.kexe

Finally Execute Hello.kexe & you will get output Hello World.


Superb, You don't need Java Virtual Machine to run your application ;)

Note : Tested on macOS & Ubuntu. Should work on Windows in same way.