Getting Started with IntelliJ IDEA
|Last Updated||23 January 2020|
Setting up the environment
In this tutorial we're going to use IntelliJ IDEA. To get started, install a recent version of IntelliJ IDEA.
Kotlin is bundled with IntelliJ IDEA starting from version 15.
As an alternative to using IntelliJ IDEA, you can compile and execute Kotlin applications using the command line compiler. For details, see Working with the Command Line Compiler.
Creating a new project
Once you have IntelliJ IDEA installed, it's time to create your first Kotlin application.
Create a new Project from File | New. Select the Kotlin | JVM | IDEA project type.
Give your project a name and select an SDK version for it.
Now you have the new project created with the following folder structure:
Create a new Kotlin file under the source folder. It can be named anything. Let's call it app.
Once the file is created, add the
mainfunction which is the entry point to a Kotlin application. IntelliJ IDEA offers a template to do this quickly. Just type main and press tab.
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.
Congratulations! You now have your first Kotlin application running.