Kotlin – Getting Started with IntelliJ IDEA

Setting up the environment:

Install a recent version of IntelliJ IDEA.

Kotlin is bundled with IntelliJ IDEA starting from version 15.

You can download the free Community Edition (or full-fledged Ultimate Edition) from the JetBrains website

Creating a new project

Once you have IntelliJ IDEA installed, it’s time to create your first Kotlin application.

1. Create a new Project from File | New. Select the Kotlin | JVM | IDEA project type.

2. Give your project a name and select an SDK version for it.

Now you have the new project created with the following folder structure:

3. Create a new Kotlin file under the source folder. It can be named anything. Let’s call it app.

4. Once the file is created, add the main function which is the entry point to a Kotlin application. IntelliJ IDEA offers a template to do this quickly. Just type main and press tab.

5. Add a line of code to print out ‘Hello, World!’.

Running the application

Now the application is ready to run. The easiest way is to click the green Run icon in the gutter and select Run ‘AppKt’.

If everything went well, you’ll see the result in the Run tool window.

Write a Reply or Comment

Your email address will not be published.