Kotlin: Quick Start on command line

This post describes how to start Kotlin on command line.

https://kotlinlang.org/docs/command-line.html


What is Kotlin?

Kotlin is a programming language running on JVM. It is becoming popular to implement Android apps.

https://kotlinlang.org/


Install

If you have not installed SDKMAN, see https://web-quickstart.blogspot.com/2021/04/sdkman-quick-start.html

% sdk install kotlin

...

% kotlin -version 

Kotlin version 1.4.31-release-344 (JRE 11.0.10+9)


hello world

% cat hello.kt 

fun main() {

  println("Hello, World!")

}

% kotlinc hello.kt

HelloKt.class is created

% java HelloKt

Hello, World!


hello world (mix Java code)

The following code shows the compatibility and difference between Kotlin vs Java.

Note that you probably should not mix them on production code.

% cat hello.kt 

fun main() {

  println("Hello, World!")

  System.out.println("Java Way");

}

% kotlinc hello.kt

% java HelloKt

Hello, World!

Java Way


Comments

Popular posts from this blog

Selenide: Quick Start

Minikube Installation for M1 Mac

Three.js Quick Start - Run Spinning-Cube Example