Setting Up IntelliJ IDEA
In this page:
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?
fun main() {
println("IntelliJ IDEA gives instant feedback while you type Kotlin")
}
Login to try C/C++/Java/PHP code in the editor
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
fun main() {
println("A new Kotlin project created in IntelliJ IDEA")
}
Login to try C/C++/Java/PHP code in the editor
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
fun main() {
println("Click the green run arrow next to main() to execute this")
}
Login to try C/C++/Java/PHP code in the editor
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
fun main() {
val message = "IntelliJ suggests fixes with Alt+Enter"
println(message)
}
Login to try C/C++/Java/PHP code in the editor
- Assuming a Kotlin project must always be created as an Android project inside IntelliJ, when a plain Kotlin/JVM project works fine.
- Forgetting to select a JDK when creating the project, which causes the IDE to fail to find a runtime to compile against.
- Ignoring the red/yellow underlines the IDE shows and running the code anyway instead of fixing the flagged issue first.
- 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: