Kotlin Hello World


Kotlin Hello World

In tutorial we are going to create Hello World example in Kotlin and run in Eclipse.

In tutorial we are going to create Hello World example in Kotlin and run in Eclipse.

Kotlin Hello World Example

In this tutorial we are creating Hello World Example in Kotlin programming language and then run the example in Eclipse. In last tutorial we have installed Kotlin plugin in Eclipse IDE and now we will create our first Kotlin program.

You will learn to write and run your first Kotlin program in Eclipse IDE. Eclipse Kotlin plugin helps developers to write Kotlin programming language code in Eclipse and then it from the Eclipse IDE.

As mentioned in previous tutorial Kotlin is fully interoperable with Java and you can use all existing library with Kotlin programming language.

Writing Hello World Kotlin Example

Open Eclipse IDE and then select Menu->File-> New Project as shown below:

Kotlin Eclipse Example

Now in the next screen search for Kotlin and it will display following options:

Kotlin new project in Eclipse

Select Kotlin project and then enter the project name "HelloWorldExample" as shown below:

New Kotlin project

Then click finish. This will create a new project in Eclipse IDE. Create new package as shown below:

Java new package

Then write click on the package and select new-> other and then Kotlin file as shown below:

Kotlin file

Select Kotlin file and click next. Following screen will displayed:

Kotlin tutorila

Enter file name "HelloWorld" and click finish. Eclipse will create a new file HelloWorld.kt. Add following code into the file:

package net.roseindia

	fun main(args: Array) {
		println("Hello, World!")

Above code defines main method in Kotlin and its println function prints "Hello, World!" message on the console.

To run the example right click in the file and select Run As -> Kotlin Application as shown below:

Run Kotlin application

This will run application in Eclipse and print "Hello, World!" message on console.

In this tutorial you learned how to create Hello World application in Kotlin. In the next section you will learn to create and use Kotlin Variables in your program.