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:
Now in the next screen search for Kotlin and it will display following options:
Select Kotlin project and then enter the project name "HelloWorldExample" as shown below:
Then click finish. This will create a new project in Eclipse IDE. Create new package as shown below:
Then write click on the package and select new-> other and then Kotlin file as shown below:
Select Kotlin file and click next. Following screen will displayed:
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:
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.