Thursday, 17 August 2017

Kotlin Installation and Hello World code in Ubuntu 16.04 LTS and Mac OS X - Go Kotlin

Hello, everyone. We're really excited to share our new blog series on Kotlin for everybody who can code it for the server, Android, and even front-end too.

You can always check out and subscribe to our Web and Server Development post at i-visionblog series and Android related post in Android friendly series.

Let's get started with Kotlin installation and running your first program hello world from your command line. 


If you're in Linux platform or Mac OS X you can go straight ahead to Terminal and download and install via sdkman.
$ curl -s | bash
Next, open a new terminal and install Kotlin with:
$ sdk install kotlin

carry out this command additionally to add sdkman to your path

$ source "$HOME/.sdkman/bin/"
To test whether the kotlin has successfully installed in your machine, launch another terminal and start executing the below command.

$ kotlinc -version

This will output the currently installed version of the kotlinc executable and you can explore the help command.

First Program

Open your favorite editor and save the file as the preferrable filename with extension as kt ( example hello.kt )

fun main(args: Array<String>) {
    println("Welcome to Kotlin!")

Once done, save the file and head to the terminal to compile and run your program.

$ kotlinc hello.kt

The above command will compile and generate the corresponding class file which can be executed.

$kotlin HelloKt

Which will execute the program and print the appropriate text in the console. Thus we could able to install and start writing our first beginner level code in kotlin.

Hope you have enjoyed this post. We're coming up with the collection of a helpful blog post to learn kotlin easily. If you wish to subscribe to our blog just drop your email in our subscription box. If you have any comments, bugs or hugs just drop it as comments. Share is care.

Popular Posts