Edit Page

Getting Started with IntelliJ IDEA

Last Updated 2 November 2015
This tutorial walks you through creating a simple Hello World application using IntelliJ IDEA.

Setting up the environment

In this tutorial we're going to use IntelliJ IDEA. You can download the free Open Source Community Edition from JetBrains. For instructions on how to compile and execute Kotlin applications using the command line compiler, see Working with the Command Line Compiler.

If you are new to the JVM and Java, check out the JVM Minimal Survival Guide. If you are new to IntelliJ IDEA, check out the The IntelliJ IDEA Minimal Surivial Guide.

  1. Kotlin is shipped with IntelliJ IDEA 15 (download).

    To use Kotlin with the previous versions or Android Studio, we need to manually install the latest Kotlin Plugin. Under Preferences (OSX) or Settings (Windows/Linux) > Plugins > Browse Repositories type Kotlin to find the Kotlin plugin. Click Install and follow the instructions.

    Kotlin Plugin

  2. Create a New Project. We select Java Module and select the SDK. Kotlin works with JDK 1.6+. Also, select the Kotlin (Java) checkbox.

    Kotlin New Project

  3. Then we click the Create button to specify the Kotlin runtime. We can either copy it to our project folder or use the bundle from the plugin.

    Kotlin Select Technologies

  4. Give our project a name on the next step.

    Kotlin Project Name

  5. We should now have the new project created with the following folder structure:

    Kotlin Folder Structure

  6. Let's create a new Kotlin file under the source folder. It can be named anything. In our case, we will call it app.

    Kotlin New File

  7. Once we have the file created, we need to type the main routine, which is the entry point to a Kotlin application. IntelliJ IDEA offers us a template to do this quickly. Just type main and press tab.

    Kotlin Main Fun

  8. Let's now add a line of code to print out 'Hello, World!'.

    Kotlin New File

  9. Now we can run the application. The easiest way is to click on the Kotlin icon in the gutter and select Run 'AppKt'.

    Kotlin Folder Structure

  10. If everything went well, we should now see the result in the Run tool window.

    Kotlin Folder Structure

Congratulations! We now have our first application running.