Kotlin runs on the JVM and requires a Java Development Kit (JDK). For most learners, installing IntelliJ IDEA or Android Studio is enough — Kotlin support is built in. For command-line use, install the standalone Kotlin compiler (kotlinc).
Prerequisites
Requirement
Minimum
Recommended
JDK
JDK 8
JDK 17 or JDK 21 (LTS)
RAM
4 GB
8 GB or more for IDE
Disk space
2 GB
4 GB+ (IDE + SDK)
OS
Windows 10+, macOS 10.14+, or modern Linux
Option A — Install JDK first
Download a JDK from Adoptium (Eclipse Temurin), Oracle, or use your OS package manager. Verify installation:
Bash — Verify JDKjava -version
javac -version
# Example output: openjdk version "17.0.x"
Option B — Standalone Kotlin compiler (command line)
Download the latest Kotlin release from GitHub releases (kotlin-compiler-*.zip). Extract and add the bin folder to your PATH.
Windows PowerShell — Add to PATH (session)$env:PATH += ";C:\kotlin\kotlinc\bin"
kotlinc -version
macOS / Linux — Extract and verifyunzip kotlin-compiler-*.zip -d ~/kotlin
export PATH="$HOME/kotlin/kotlinc/bin:$PATH"
kotlinc -version
You rarely need a separate kotlinc install if you use IntelliJ or Gradle — the Kotlin plugin and Gradle plugin download the compiler automatically for your project.
2IntelliJ IDEA Setup
IntelliJ IDEA is the IDE from JetBrains — the same team that created Kotlin. Kotlin support is included out of the box in both Community and Ultimate editions.
Settings → Build, Execution, Deployment → Build Tools → Gradle — JVM version for Gradle
View → Tool Windows → Gradle — run tasks like build and test
Android development: Use Android Studio instead — it is IntelliJ-based and ships with the Android SDK, emulator, and Kotlin plugin preconfigured.
3Kotlin Playground
Kotlin Playground is a free online editor at play.kotlinlang.org. Write Kotlin code in your browser, run it instantly, and share snippets — no installation required.
Replace the default code with your Kotlin snippet.
Click the Run button (or press the run shortcut shown in the toolbar).
View output in the panel below the editor.
Use Share to generate a link you can send to others or embed in docs.
Playground examplefun main() {
val numbers = listOf(1, 2, 3, 4, 5)
val evens = numbers.filter { it % 2 == 0 }
println("Evens: $evens")
println("Sum: ${numbers.sum()}")
}
Playground features
Instant Run
Compile and execute JVM Kotlin in the cloud — great for quick experiments.
Shareable URLs
Save and share code snippets with classmates or in tutorials.
Syntax Highlighting
Full Kotlin syntax support with error messages in the output panel.
Learning First
Ideal before installing an IDE — try concepts from this tutorial series online.
When to use Playground vs IDE
Use Playground for small snippets and sharing. Switch to IntelliJ or Android Studio when you need multi-file projects, Gradle builds, debugging, and Android emulators.
4Project Structure
A typical Kotlin JVM project created with Gradle in IntelliJ follows a standard layout. Understanding folders helps you navigate real-world apps and Android modules.
Root project name; lists submodules in multi-module apps
gradle/wrapper/
Ensures everyone uses the same Gradle version
Sample build.gradle.kts
build.gradle.ktsplugins {
kotlin("jvm") version "2.0.0"
application
}
group = "com.example"
version = "1.0-SNAPSHOT"
repositories {
mavenCentral()
}
dependencies {
testImplementation(kotlin("test"))
}
kotlin {
jvmToolchain(17)
}
application {
mainClass.set("com.example.MainKt")
}
Package naming convention
Kotlin packages use reverse domain notation. File path must match package declaration:
src/main/kotlin/com/example/app/Main.ktpackage com.example.app
fun main() {
println("Package: com.example.app")
}
Android module (preview)
Android projects add an app/ module with a similar layout under app/src/main/ — Kotlin in kotlin/ or java/, layouts in res/layout/, and manifest at AndroidManifest.xml. You'll explore this in Kotlin Android Development.
Generated folders: Do not commit build/ or .gradle/ to Git — add them to .gitignore. Commit source, Gradle wrapper, and build scripts.
5Summary Cheatsheet
Topic
Key Takeaway
Installing Kotlin
Need JDK 17+; use IntelliJ, standalone kotlinc, or SDKMAN
IntelliJ IDEA
Community edition is free; New → Kotlin JVM project → run main
Kotlin Playground
Browser-based at play.kotlinlang.org — no install, shareable links
Project Structure
src/main/kotlin, build.gradle.kts, Gradle wrapper
Verify setup
Run Hello World in IDE, Playground, or via kotlinc + java -jar
Explanation: The application plugin uses mainClass to know which class contains fun main() for run tasks.
16
gradle.properties typically stores?
AJVM args and shared Gradle/Kotlin build options
BMachine-specific SDK paths only
CCompiled bytecode output
DGit credentials
Explanation: gradle.properties holds JVM heap settings, Kotlin options, and other team-shared build flags.
17
For dedicated Android app development, you should use?
AIntelliJ Community only
BAndroid Studio
CKotlin Playground only
DStandalone kotlinc only
Explanation: Android Studio is IntelliJ-based and ships with Android SDK, emulator, and Kotlin preconfigured.
18
Which folders should NOT be committed to Git?
Abuild/ and .gradle/
Bsrc/main/kotlin/
Cgradle/wrapper/
Dbuild.gradle.kts
Explanation: build/ and .gradle/ are generated locally; commit source, wrapper, and build scripts instead.
19
When using IntelliJ with Gradle, do you usually need standalone kotlinc?
ANo — Gradle and the Kotlin plugin download the compiler
BYes, always required separately
COnly on Windows
DOnly for Android projects
Explanation: The Kotlin Gradle plugin resolves the compiler version automatically for your project.
20
Top-level main() in file Main.kt in package com.example becomes JVM class?
Acom.example.Main
Bcom.example.MainKt
CMain.main
DKotlinMain
Explanation: Kotlin generates a MainKt facade class for top-level functions — referenced in mainClass.set().
Click an option to select, then check answers.
Kotlin Setup Interview Q&A
15 topic-focused questions for interviews and revision.
1What are the main steps to set up Kotlin development on a new machine?easy
Answer: Install JDK 17+, choose IntelliJ IDEA or Android Studio, optionally install kotlinc or use SDKMAN, create a Kotlin JVM project, and verify by running a Hello World main() function.
2What is the difference between kotlinc and using Gradle for Kotlin builds?easy
Answer: kotlinc is the standalone compiler for single-file or script use; Gradle with the Kotlin plugin manages multi-file projects, dependencies, tests, and reproducible builds via build.gradle.kts.
3Why is JDK 17 or 21 recommended for Kotlin projects?medium
Answer: Modern IntelliJ, Gradle, and jvmToolchain settings target LTS JDK versions; older JDKs may cause IDE warnings, sync failures, or missing language features.
4How do you create a new Kotlin JVM project in IntelliJ IDEA?easy
Answer: File → New → Project, select Kotlin on the left, choose JVM | IDEA or Gradle, set JDK to 17+, name the project, then add a Main.kt under src/main/kotlin and click Run beside fun main().
5When should you use Kotlin Playground instead of an IDE?easy
Answer: Use Playground for quick snippets, learning concepts, and sharing code links without installation; switch to an IDE for multi-file projects, Gradle builds, debugging, and Android emulators.
6Explain the standard Kotlin Gradle project folder layout.medium
Answer: Source in src/main/kotlin and tests in src/test/kotlin; build.gradle.kts for plugins and dependencies; settings.gradle.kts for project name; gradle/wrapper for consistent Gradle version; build/ for generated output.
7What does kotlin("jvm") version "2.0.0" in build.gradle.kts do?medium
Answer: It applies the Kotlin JVM plugin at version 2.0.0, enabling Kotlin compilation, stdlib dependency resolution, and Kotlin-specific Gradle tasks for JVM targets.
8How does SDKMAN simplify Kotlin setup on macOS/Linux?easy
Answer: SDKMAN installs and switches JDK and Kotlin versions with commands like sdk install kotlin and sdk use kotlin, avoiding manual PATH and archive extraction steps.
9What is the purpose of the Gradle wrapper files (gradlew, gradle/wrapper/)?medium
Answer: They pin a specific Gradle version so every developer and CI machine builds with the same Gradle release without a global Gradle install.
10Why is mainClass.set("com.example.MainKt") needed in build.gradle.kts?hard
Answer: Top-level main() in Main.kt compiles to a JVM class named MainKt in the declared package; the application plugin needs this fully qualified name to run the project with gradle run.
11IntelliJ IDEA Community vs Ultimate for Kotlin — when is Ultimate worth it?medium
Answer: Community is enough for Kotlin/JVM learning and CLI apps; Ultimate adds Spring, Ktor, database tools, and advanced frameworks — useful for full-stack or enterprise Kotlin development.
12How do you verify JDK installation before writing Kotlin code?easy
Answer: Run java -version and javac -version in a terminal; both should report JDK 17+ (e.g. Temurin or OpenJDK) before installing Kotlin or opening IntelliJ.
13What goes in src/test/kotlin vs src/main/kotlin?easy
Answer: src/main/kotlin holds production application code; src/test/kotlin holds unit tests (e.g. JUnit or kotlin("test")) that Gradle runs via ./gradlew test.
14How do package names relate to folder paths in Kotlin projects?medium
Answer: Use reverse-domain notation (com.example.app); the file path under src/main/kotlin must match — com/example/app/Main.kt for package com.example.app.
15Describe troubleshooting when kotlinc is not recognized in the terminal.hard
Answer: Confirm the kotlin-compiler bin folder is on PATH, restart the terminal, verify with kotlinc -version, or skip standalone install and use IntelliJ/Gradle which download the compiler automatically.