Last Updated | 23 April 2019 |
In this tutorial we're going to use IntelliJ IDEA. 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 Survival Guide.
To get started, install a recent version of IntelliJ IDEA. Kotlin is bundled with IntelliJ IDEA starting from version 15. You can download the free Community Edition from JetBrains.
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 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.
Add a line of code to print out 'Hello, World!'.
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.
© 2010–2019 JetBrains s.r.o.
Licensed under the Apache License, Version 2.0.
https://kotlinlang.org/docs/tutorials/getting-started.html