In this tutorial, we will learn how to create a simple Kotlin hello world application using Eclipse IDE.
First of all, we need the Eclipse IDE installed on your system. You can download its latest version from the download page. The "Eclipse IDE for Java Developers" bundle is recommended.
To add the Kotlin support to your Eclipse IDE, install the Kotlin Plugin for Eclipse.
First of all, we need the Eclipse IDE installed on your system. You can download its latest version from the download page. The "Eclipse IDE for Java Developers" bundle is recommended.
To add the Kotlin support to your Eclipse IDE, install the Kotlin Plugin for Eclipse.
Install Kotlin Plugin from Eclipse Marketplace: Go to Help → Eclipse Marketplace, and search for Kotlin.
Let’s verify the plugin’s installation switching to Kotlin perspective in eclipse. Go to Window → Perspective → Open Perspective → Other. A window will open which will show Kotlin as a new perspective. Select Kotlin and click Open to open Kotlin perspective -
Let’s now create a new project. Select File → New → Kotlin Project. Enter the project’s name "helloworld" and click finish -
Let's create a package "net.javaguides.helloworld" and the project will look like this -
Let's create a new Kotlin file under "net.javaguides.helloworld" package. Select File → New → Other → Kotlin File.
You can enter the name without the .kt extension. The eclipse will add it automatically.
Click install to install the plugin. You will need to restart eclipse once the installation is finished.
Let’s verify the plugin’s installation switching to Kotlin perspective in eclipse. Go to Window → Perspective → Open Perspective → Other. A window will open which will show Kotlin as a new perspective. Select Kotlin and click Open to open Kotlin perspective -
Create Kotlin Project in Eclipse
Let's create a package "net.javaguides.helloworld" and the project will look like this -
Create a Kotlin Simple Program
You can enter the name without the .kt extension. The eclipse will add it automatically.
Once you have a source file, add the main function - the entry point to a Kotlin application. You can simply type main and invoke code completion by hitting Ctrl + Space.
package net.javaguides.helloworld fun main(args: Array<String>) { }Add a simple line of Kotlin code to print a message:
package net.javaguides.helloworld fun main(args: Array<String>) { println("Hello World!"); }That's all, we have created a Kotlin hello-world program. In the next step, we will run this program.
Comments
Post a Comment
Leave Comment