← Back to Kotlin Course | Chapter 1: Setup & Basics | Lesson 3 of 7

Setting Up IntelliJ IDEA

IntelliJ IDEA is a smart text editor made for Kotlin that helps you write code correctly by pointing out mistakes as you type.

Why IntelliJ IDEA?

IntelliJ IDEA is JetBrains' own IDE, and because JetBrains also created Kotlin, IntelliJ offers the most complete Kotlin support: instant error checking, auto-completion, refactoring tools, and an integrated debugger.

Note: The free Community Edition fully supports plain Kotlin/JVM projects like the ones in this course.

Example: Why IntelliJ IDEA?

markup
fun main() {
    println("IntelliJ IDEA gives instant feedback while you type Kotlin")
}

Creating a New Kotlin Project

From the Welcome screen, choosing New Project -> Kotlin lets you pick a build system (Gradle or IntelliJ) and a JDK. A minimal Kotlin/JVM console project needs nothing more than that to start running code.

Example: Creating a New Kotlin Project

markup
fun main() {
    println("A new Kotlin project created in IntelliJ IDEA")
}

Running Code with the Green Arrow

IntelliJ shows a small green triangle next to any fun main() function; clicking it compiles and runs that file immediately, showing output in the Run panel at the bottom of the window.

Note: Shift+F10 (or Ctrl+R on macOS) reruns the last executed configuration without touching the mouse.

Example: Running Code with the Green Arrow

markup
fun main() {
    println("Click the green run arrow next to main() to execute this")
}

Using Code Inspections

IntelliJ underlines problematic code in red (errors) or yellow (warnings/suggestions) as you type, and Alt+Enter opens quick-fixes for many of them, such as adding a missing import or simplifying an expression.

Example: Using Code Inspections

markup
fun main() {
    val message = "IntelliJ suggests fixes with Alt+Enter"
    println(message)
}
Common Mistakes
  1. Assuming a Kotlin project must always be created as an Android project inside IntelliJ, when a plain Kotlin/JVM project works fine.
  2. Forgetting to select a JDK when creating the project, which causes the IDE to fail to find a runtime to compile against.
  3. Ignoring the red/yellow underlines the IDE shows and running the code anyway instead of fixing the flagged issue first.
Chapter Summary
  • IntelliJ IDEA is made by JetBrains, the same company that created Kotlin, so its Kotlin support is first-class.
  • The free Community Edition is enough for plain Kotlin/JVM projects; Android and web projects benefit from Ultimate.
  • Creating a new project asks you to pick a JDK and a build system (Gradle, Maven, or IntelliJ's own builder).
  • IntelliJ's built-in Run button compiles and executes your main() function with one click.
🔒

Chapter Quiz — Complete all 7 topics to unlock

0/7 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.