How To Create Kotlin Project In IntelliJ IDEA

In this tutorial, we will learn about how to create kotlin project in IntelliJ IDEA. We will see the step by step process to create a project in IntelliJ IDEA.

IntelliJ IDEA is java integrated development environment for developing computer software. It is developed by JetBrains. It is available as an Apache 2 Licensed community edition, and in a proprietary commercial edition. Both can be used for commercial development.

Note: This is next part in the Kotlin Tutorial series. You can visit Introduction to Kotlin Programming language tutorial to know more.

Now, we are starting the process to create kotlin project in IntelliJ IDEA.
At this point, we are assuming that you have successfully installed IntelliJ IDEA. If not, you can download and install IntelliJ IDEA from Download IntelliJ IDEA. Kotlin is bundled with IntelliJ IDEA starting from version 15.

Now, we will go through step by step and see how you can create a new project.

Follow steps below to create a new project –
1. if you are at Welcome to IntelliJ IDEA screen, select Create New Project.

Create Kotlin Project in IntelliJ IDEA

IntelliJ IDEA welcome screen

2. Select Java Module and Select the SDK. You need JDK 1.6+ to work with Kotlin. So, Select at-least 1.6 version. In the Additional Libraries and Frameworks fields, select Kotlin(Java) option. After entering all details, click Next.

IntelliJ IDEA: Create Kotlin Project - Step 2

IntelliJ IDEA: Create Kotlin Project – Step 2

3. In the next screen, Provide project name and select project location where you want to store the project. Then, click Finish.

IntelliJ IDEA: Create Kotlin Project - Step 3

IntelliJ IDEA: Create Kotlin Project – Step 3

4. After this, a project will be create. Folder structures of the newly created project will be as below.

IntelliJ IDEA: Create Kotlin Project Step 4

IntelliJ IDEA: Create Kotlin Project Step 4

5. As you have noticed, there is no kotlin file created yet. So, you need to create a new kotlin file and write you first kotlin program to print Hello World. So, create a new kotlin file. Select HelloWorld(Project Root file) => src folder and right click on it. Now, go to New => Kotlin File/Class to create a new File. We will name this file app.kt. However, you can name it as per your choice. Below image clearly depicts the process.

IntelliJ IDEA: Create Kotlin Project - Step 5

IntelliJ IDEA: Create Kotlin Project – Step 5




6. We have successfully create a new kotlin file. Now, our job is to write main routine which is entry point for any kotliin application. IntelliJ IDEA offers a template for this process. Type main and press tab. You will see that a method is created in kotlin file.

IntelliJ IDEA: Create Kotlin Project  - Step 6

IntelliJ IDEA: Create Kotlin Project – Step 6

7. Now, write the code to print Hello World.

IntelliJ IDEA: Create Kotlin Project - Step 7

IntelliJ IDEA: Create Kotlin Project – Step 7

That’s it. Run the application and you will see the output as shown below.

IntelliJ IDEA: Create Kotlin Project - Step 8

IntelliJ IDEA: Create Kotlin Project – Step 8

That’s it. We have successfully gone through different steps to create kotlin project in IntelliJ IDEA.

Leave a Reply