Before you write Kotlin, you need a place to run it. There are four good options. You don’t need all of them: pick one and move on to the next lesson.
| Option | Install needed? | Best for |
|---|---|---|
| Kotlin Playground | No, it runs in the browser | Trying code right now, learning the basics |
| IntelliJ IDEA | Yes | Learning Kotlin properly, console programs |
| Android Studio | Yes | Android apps |
| Command line (kotlinc) | Yes | Scripts, servers, people who like the terminal |
Recommendation for this course: use the Kotlin Playground for the first few lessons, then IntelliJ IDEA once you start reading user input.
Page Contents
Option 1: Kotlin Playground (no install)
- Open play.kotlinlang.org in your browser.
- You’ll see a small program with a
mainfunction already written. - Change the code and click Run. The output appears below the editor.
The Playground is perfect for the examples in this course. Its one limitation is that it can’t read keyboard input, so programs that use readln() need IntelliJ IDEA or Android Studio.
Option 2: IntelliJ IDEA
IntelliJ IDEA is made by JetBrains, the company that created Kotlin, so Kotlin support is built in. The free edition is all you need.
- Download IntelliJ IDEA from jetbrains.com/idea and install it.
- Choose New Project, then pick Kotlin as the language.
- Give the project a name and select a JDK. If you don’t have one, IntelliJ can download it for you, or see our guide to installing the Java JDK.
- Open the
Main.ktfile insrc, and click the green Run arrow next tofun main().
The output appears in the Run window at the bottom. This is also where you type input for programs that use readln().
Option 3: Android Studio
If your goal is Android apps, download Android Studio. Kotlin is already included and is the default language for new projects.
To run plain Kotlin lessons (not an app) in Android Studio, create a Kotlin file with a main function in your project and click the Run arrow next to it. For learning the language itself, IntelliJ IDEA or the Playground is simpler.
Option 4: Command line (kotlinc)
Install the Kotlin compiler:
- macOS:
brew install kotlin - Linux/macOS with SDKMAN:
sdk install kotlin - Windows: download the compiler zip from the Kotlin releases page on GitHub, unzip it, and add its
binfolder to your PATH.
You also need a Java JDK installed. Then create a file called hello.kt:
fun main() {
println("Hello, Kotlin!")
}Output:
Hello, Kotlin!
Compile and run it:
kotlinc hello.kt -include-runtime -d hello.jar java -jar hello.jar
Check that it works
Whichever option you chose, run this program:
fun main() {
val language = "Kotlin"
println("Hello from $language!")
println("2 + 3 = ${2 + 3}")
println("Kotlin version: ${KotlinVersion.CURRENT}")
}Output:
Hello from Kotlin! 2 + 3 = 5 Kotlin version: 2.2.21
If you see output like the above, you’re ready. (Your Kotlin version number may differ.)
Common problems
| Problem | Fix |
|---|---|
| “No JDK specified” in IntelliJ | Open project settings, pick a JDK, or let IntelliJ download one |
kotlinc: command not found | The compiler’s bin folder isn’t on your PATH. Restart the terminal after adding it |
| Nothing happens when reading input in the Playground | The Playground doesn’t support input. Use IntelliJ IDEA |
| Green Run arrow is missing | The function must be exactly fun main() (or fun main(args: Array<String>)) at the top level of the file |
FAQ
Can I learn Kotlin without installing anything?
Yes. The Kotlin Playground runs in your browser and handles every example in the first modules of this course.
Is IntelliJ IDEA free?
Yes, IntelliJ IDEA has a free edition that fully supports Kotlin. The paid version adds tools for web and enterprise development.
Do I need Java to use Kotlin?
You don’t need to know Java. To run Kotlin on your computer, you need a JDK installed, because Kotlin compiles to JVM bytecode. IntelliJ IDEA can download one for you.
