Kotlin Setup
To write and run Kotlin programs, you need a few tools installed on your computer. This topic walks you through two paths: using IntelliJ IDEA (recommended for beginners) and using the command line.
What You Need
- JDK (Java Development Kit) – Kotlin runs on the JVM, so JDK must be installed first.
- IntelliJ IDEA – The best editor for Kotlin, made by the same company that created Kotlin.
Step 1: Install the JDK
The JDK lets your computer understand and run Java and Kotlin bytecode.
- Visit adoptium.net or oracle.com/java.
- Download JDK 17 or later (LTS version recommended).
- Run the installer and follow the prompts.
- Verify the installation by opening a terminal and typing:
java -versionYou should see output like: java version "17.0.x"
Step 2: Install IntelliJ IDEA
- Visit jetbrains.com/idea.
- Download the Community Edition — it is free and includes Kotlin support.
- Install it like any other application on your operating system.
- Open IntelliJ IDEA after installation.
Step 3: Create Your First Kotlin Project
Setup Flow Diagram:
Open IntelliJ IDEA
│
▼
Click "New Project"
│
▼
Select "Kotlin" as language
│
▼
Select "JVM" as build target
│
▼
Choose a project name and location
│
▼
Click "Create"
│
▼
Project opens with src/main/kotlin folder
IntelliJ creates a project structure automatically. Your Kotlin files go inside the src/main/kotlin folder.
Step 4: Verify Kotlin Is Working
Right-click on the kotlin folder, select New → Kotlin File/Class, and name it Main. Add this code:
fun main() {
println("Kotlin is ready!")
}Click the green play button at the top of the editor. The output panel at the bottom shows:
Kotlin is ready!Alternative: Online Kotlin Playground
If you do not want to install anything yet, use the official Kotlin playground at play.kotlinlang.org. Type code in your browser and run it instantly. This works for learning, but you will need a local setup for real projects.
Alternative: Command Line Setup
Developers who prefer the terminal can install the Kotlin compiler directly.
Install via SDKMAN (Linux/Mac)
sdk install kotlinInstall via Homebrew (Mac)
brew install kotlinVerify Installation
kotlin -versionCompile and Run a File
kotlinc Main.kt -include-runtime -d main.jar
java -jar main.jarProject Folder Structure
MyKotlinProject/
├── src/
│ └── main/
│ └── kotlin/
│ └── Main.kt ← Your Kotlin files go here
├── build.gradle.kts ← Build configuration
└── settings.gradle.kts ← Project settings
You only need to work inside the kotlin folder for now. The build files handle compilation automatically when you press the run button in IntelliJ.
