Thursday 16 November 2017

Setting up Kotlin in Eclipse

Open Eclipse. Help -> Eclipse Marketplace.
Search for kotlin.
Click on the button ‘Install’ to install the kotlin plugin.

Once the installation is successful, Eclipse asks for a restart. Restart the Eclipse.

Create new Kotlin Project
Open Eclipse. File -> New -> Other.
Kotlin -> Kotlin Project.
Press Next.

In the ‘Kotlin Project’ window, give the project name as ‘Hello World’ and click on the button Finish.

Kotlin project structure looks like below.
Create HelloWorld.kt file
Right click on ‘src’ folder -> New -> Other.
Select ‘Kotlin File’ and press Next.
Give the file name as ‘HelloWorld’ and press the button ‘Finish’.
Copy below snippet to HelloWorld.kt file.

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


Run HelloWorld.kt file
Right click on source code of HelloWorld.kt file -> Run As -> Kotlin Application.
If everything goes well, you can see the message ‘Hello World’ in console.



Previous                                                 Next                                                 Home

No comments:

Post a Comment