Skip to the workspace
Pebellslearn by building
Introduction to Kotlin  ›  Lesson

Setting up the Environment

Setting up the Environment 12 minTo run Kotlin you need a JDK plus a way to compile: an IDE such as IntelliJ IDEA, the kotlinc command-line compiler, or a browser playground for quick experiments.

kotlin / Setting up the Environment

Explore each scene at your own pace.

01 · The rule

The rule

Setting up the Environment

To run Kotlin you need a JDK plus a way to compile: an IDE such as IntelliJ IDEA, the kotlinc command-line compiler, or a browser playground for quick experiments.

Create a working project and verify which compiler and target it uses.

You want to see the words "Pebble Café is open" appear on your screen, printed by a program you wrote. Before any of that, your computer needs two things: something that turns Kotlin into runnable code, and something that runs it.

The rule

JDK to run it, a compiler to build it, an editor to write it.

  • JDK (Java Development Kit). Kotlin programs for the JVM run on a Java virtual machine, so you need a JDK installed. Any recent long-term-support version works.
  • A compiler. The Kotlin compiler, kotlinc, turns .kt files into JVM class files. IDEs and build tools bundle it for you.
  • An editor. IntelliJ IDEA (made by Kotlin's own authors) and Android Studio understand Kotlin deeply: completion, error highlighting and one-click running.

Three common ways to start:

Setup Best for Install?
Kotlin Playground in the browser Trying a few lines Nothing
IntelliJ IDEA + Gradle project Real applications IDE (includes Kotlin)
JDK + kotlinc in a terminal Servers, scripts, learning the steps JDK and compiler

The terminal route shows what the IDE does behind the scenes:

kotlinc hello.kt -include-runtime -d hello.jar
java -jar hello.jar

The first line compiles hello.kt into a jar file and packs the Kotlin runtime library inside it. The second line runs that jar on the JVM.

In a real project, a build tool such as Gradle does this for you. It downloads libraries, compiles every file and packages the result. Source files usually live in src/main/kotlin.

Scene 1 of 5
Hover to wake the cannons. Drag to move, or use arrow keys when focused. Press Enter to fire a shot.