Kotlin Hello World Application using Eclipse IDE

In this tutorial, we will learn how to create a simple Kotlin hello world application using Eclipse IDE.

Setting up Kotlin in 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.
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 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 -

Create a Kotlin Simple Program

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.

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.

Running an application

To run the application, right-click somewhere in the main file and click Run As → Kotlin Application to run the application -

Output

Below screenshot shows the ouput of this kotlin hello-world example:

Free Spring Boot Tutorial | Full In-depth Course | Learn Spring Boot in 10 Hours


Watch this course on YouTube at Spring Boot Tutorial | Fee 10 Hours Full Course

Comments