|Last Updated||2 November 2015|
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.
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.
Create a New Project. We select Java Module and select the SDK. Kotlin works with JDK 1.6+. Also, select the Kotlin (Java) checkbox.
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.
Give our project a name on the next step.
We should now have the new project created with the following folder structure:
Let's create a new Kotlin file under the source folder. It can be named anything. In our case, we will call it app.
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.
Let's now add a line of code to print out 'Hello, World!'.
Now we can run the application. The easiest way is to click on the Kotlin icon in the gutter and select Run 'AppKt'.
If everything went well, we should now see the result in the Run tool window.
Congratulations! We now have our first application running.
© 2010–2017 JetBrains s.r.o.
Licensed under the Apache License, Version 2.0.