Your country

Tools that support it use your country for local currency, number formats, units and paper size. Your choice is saved only in this browser.

Type a name or a two-letter code. Use the up and down arrow keys to move through the countries, Enter to choose one and Escape to close.

Kotlin  Module 1 – Start here: Kotlin 2.4 on the JVM

Install Kotlin, a JDK and an editor

Install a JDK 25 and the Kotlin 2.4.20 compiler and check both, see how JAVA_HOME and -jvm-target decide which JVM runs what, choose an editor and pin versions.

  • Beginner
  • 15 minutes
  • Examples run with Kotlin 2.4.20 and Python 3.14.8
  • By MySmartCoPilot
Free lesson, Pro answers: 15 minutes
Free: the whole lesson. With a pass: the model answers to its 2 interview questions.

What you will learn

  • Install a JDK 25 and the Kotlin 2.4.20 command-line compiler, then confirm both versions
  • Explain which JVM runs kotlinc and your program, and how JAVA_HOME and -jvm-target change it
  • Choose an editor, IntelliJ IDEA or Android Studio, or Visual Studio Code with the Kotlin Language Server
  • Set per-project versions with mise or SDKMAN so the terminal, the editor and CI run the same toolchain

Before you start

What you’ll learn · Before you start

What you will learn

  • Install a JDK 25 and the Kotlin 2.4.20 command-line compiler, then confirm both versions
  • Explain which JVM runs kotlinc and your program, and how JAVA_HOME and -jvm-target change it
  • Choose an editor, IntelliJ IDEA or Android Studio, or Visual Studio Code with the Kotlin Language Server
  • Set per-project versions with mise or SDKMAN so the terminal, the editor and CI run the same toolchain

Before you start

On this page

Two versions decide every Kotlin run on your computer: the compiler’s, and the Java runtime’s under it. On the computer behind this page, kotlinc -version printed kotlinc-jvm 2.4.20 (JRE 25.0.4.1+1-LTS), and after one environment variable changed, the same command printed (JRE 27+35).

This lesson installs a JDK and the Kotlin 2.4.20 compiler and checks both, shows which JVM runs the compiler and which runs your program, chooses an editor, and pins the versions in files that travel with a project, so your terminal, your editor and your CI all build with the same toolchain.

kotlinc is a JVM program, so the JDK comes first

The Kotlin compiler for the JVM is written for the JVM: The Java Virtual Machine: the program that loads compiled class files and runs their bytecode on your computer's processor. Every JDK includes one, and it is Kotlin's main platform. More in “What Kotlin is and where it runs” and runs on one, and so does everything it compiles. So the first install is a JDK: The Java Development Kit: a JVM together with tools such as javac and javap. kotlinc is itself a JVM program, so it needs a JDK to run as well as to run what it compiles., and the second is kotlinc. Any vendor’s JDK 25 works; the runs in this track use Eclipse Temurin 25.0.4.1 from the Adoptium project, a long-term support release. For the compiler there are four routes:

  • The zip: download kotlin-compiler-2.4.20.zip (89,729,132 bytes) from the Kotlin 2.4.20 release on GitHub, unzip it and add its kotlinc/bin folder to your PATH. The folder holds kotlinc, kotlinr and the compilers for JavaScript and WebAssembly. The Kotlin documentation recommends this route on Windows.
  • SDKMAN: sdk install kotlin 2.4.20 installs exactly that version.
  • Homebrew on macOS: brew install kotlin, which installs whatever version the formula is at.
  • Snap on Ubuntu: sudo snap install --classic kotlin.

Then check both installs. Step through the two rounds:

Interactive · stage by stage Install, then check, in two rounds Step through the two installs and the check after each. The arrows on the side are where a failed check sends you back.
Install, then check, in two rounds, step 6 of 6. Showing Install a JDK 25, java -version (25.0.4.1 LTS), Install kotlinc 2.4.20, kotlinc -version (2.4.20 on JRE 25.0.4.1), Compile a first program. In focus: Compile a first program.older or missingcommand not foundInstall a JDK 25Temurin 25.0.4.1 herejava -version25.0.4.1 LTSInstall kotlinc 2.4.20zip or a package managerkotlinc -version2.4.20 on JRE 25.0.4.1Compile a first program

The drawing shows the whole scene; its 6 steps are listed below.

Every step as text
  1. The JDK comes first. kotlinc is itself a JVM program, and so is everything it compiles, so a JDK comes first. Any vendor's JDK 25 works; the runs on this page use Eclipse Temurin 25.0.4.1, a long-term support release.
  2. Check java. java -version must name 25. Here it printed openjdk version "25.0.4.1" LTS. An older number, or no answer at all, means the JDK's bin folder is not first on your PATH yet.
  3. Install kotlinc. Unzip kotlin-compiler-2.4.20.zip from the GitHub release and put its kotlinc/bin folder on your PATH, or let a package manager install it. SDKMAN installs the exact version you name; Homebrew installs whatever version its kotlin formula is at.
  4. Check kotlinc. kotlinc -version names the compiler and, in brackets, the Java runtime it runs on: kotlinc-jvm 2.4.20 (JRE 25.0.4.1+1-LTS). "command not found" sends you back to the PATH.
  5. Which JDK runs kotlinc. The JRE in brackets is the JDK that JAVA_HOME names, or the first java on the PATH when JAVA_HOME is not set. With JAVA_HOME set to JDK 27, the same check printed (JRE 27+35).
  6. Ready. Both checks pass, so the computer can compile and run Kotlin. The next lesson compiles a first program into three jars and runs it.

This session ran the checks on the computer behind this page:

Checking the JDK and the compiler Python · versions_session.py
from session import run

# The checks after installing: which JDK and which compiler answer, where they are, and which JVM kotlinc itself
# runs on. Then JAVA_HOME names another JDK, and kotlinc runs on that one.
run("""
java -version
kotlinc -version
kotlinr -version
which java kotlinc kotlinr
echo $JAVA_HOME
export JAVA_HOME={jdk:27}
kotlinc -version
""")

Output

$ java -version
openjdk version "25.0.4.1" LTS
OpenJDK Runtime Environment Temurin-25.0.4.1+1 (build 25.0.4.1+1-LTS)
OpenJDK 64-Bit Server VM Temurin-25.0.4.1+1 (build 25.0.4.1+1-LTS, mixed mode, sharing)
$ kotlinc -version
info: kotlinc-jvm 2.4.20 (JRE 25.0.4.1+1-LTS)
$ kotlinr -version
Kotlin version 2.4.20 (JRE 25.0.4.1+1-LTS)
$ which java kotlinc kotlinr
…/java/temurin-25.0.4+101.0.LTS/bin/java
…/kotlin/2.4.20/kotlinc/bin/kotlinc
…/kotlin/2.4.20/kotlinc/bin/kotlinr
$ echo $JAVA_HOME
…/java/temurin-25.0.4+101.0.LTS
$ export JAVA_HOME=…/java/temurin-27.0.0+35
$ kotlinc -version
info: kotlinc-jvm 2.4.20 (JRE 27+35)

Recorded with Python 3.14.8 on macOS 26 arm64. To run it yourself: mise exec python@3.14.8 -- python3 versions_session.py

java -version names the JDK, and kotlinc -version names the compiler and, in brackets, the Java runtime the compiler itself runs on. which shows where each command lives, here in the folders of a version manager. The kotlinc script picks its Java runtime from JAVA_HOME: An environment variable that names the folder of a JDK, the one that holds bin. kotlinc and kotlinr run on the java of the JDK it names, before any java on the PATH. when it is set, and from the first java on the PATH otherwise: once JAVA_HOME named JDK 27, the same kotlinc reported (JRE 27+35), with nothing else changed.

Checking java but not JAVA_HOME

java -version can say 25 while JAVA_HOME still names an older JDK, and then kotlinc and kotlinr run on the older one. Check kotlinc -version too: the JRE in its brackets is the one the compiler runs on.

Checkpoint

Check: Installing and checking a JDK and kotlinc

  1. Question 1 of 2 Why must a JDK be installed before kotlinc can compile anything?

    Choose one answer.

    Show the answer: Question 1 of 2

    Answer: kotlinc is itself a JVM program, so it needs a Java runtime to start

    kotlinc runs on a JVM and writes class files that a JVM runs. So the JDK comes first, and kotlinc -version names the Java runtime it found, for example kotlinc-jvm 2.4.20 (JRE 25.0.4.1+1-LTS).

  2. Question 2 of 2 java -version names 25.0.4.1, but kotlinc -version prints (JRE 21.0.12.1+1-LTS). Which JDK runs the compiler, and why?

    Choose one answer.

    A hint

    Where does the kotlinc script look first for its java?

    Show the answer: Question 2 of 2

    Answer: JDK 21, because JAVA_HOME names it, and kotlinc takes JAVA_HOME before the PATH

    kotlinc uses $JAVA_HOME/bin/java when JAVA_HOME is set, and the first java on the PATH otherwise. In the lesson's session, setting JAVA_HOME to JDK 27 made the same kotlinc report (JRE 27+35).

A JVM runs class files up to its own version

Every class file carries a class-file version: The number in a .class file that says which Java version's bytecode it holds: 52 for Java 8, 69 for Java 25 and 70 for Java 26. A JVM refuses a number above its own., the level of the bytecode in it, and a JVM runs class files up to its own level only. kotlinc chooses that level with -jvm-target: The kotlinc option that sets the bytecode level of the class files it writes: 1.8 by default, and 9 to 26 in Kotlin 2.4.20. A JVM runs class files up to its own level only.: 1.8 by default, and any of 9 to 26 in Kotlin 2.4.20. This session compiles one small program for four levels, reads the versions of three of them with javap, a tool of every JDK, and runs the Java 26 build on two JDKs:

target/Hello.kt Kotlin · target/Hello.kt
fun main() {
    println("Running on Java ${Runtime.version().feature()}")
}
Four bytecode levels and two JDKs Python · target_session.py
from session import run

# One program compiled for four bytecode levels; javap prints the class-file version of three of them. Then the
# Java 26 build runs on JDK 25, which refuses it, and on JDK 27, which runs it.
run("""
cd target
kotlinc Hello.kt -d default
javap -v -cp default HelloKt | grep major
kotlinc Hello.kt -jvm-target 21 -d jvm21
javap -v -cp jvm21 HelloKt | grep major
kotlinc Hello.kt -jvm-target 25 -d jvm25
javap -v -cp jvm25 HelloKt | grep major
kotlinc Hello.kt -jvm-target 26 -d jvm26
kotlinr -cp jvm25 HelloKt
!kotlinr -cp jvm26 HelloKt
export JAVA_HOME={jdk:27}
kotlinr -cp jvm26 HelloKt
!kotlinc Hello.kt -jvm-target 27 -d jvm27
""")

Output

$ cd target
$ kotlinc Hello.kt -d default
$ javap -v -cp default HelloKt | grep major
  major version: 52
$ kotlinc Hello.kt -jvm-target 21 -d jvm21
$ javap -v -cp jvm21 HelloKt | grep major
  major version: 65
$ kotlinc Hello.kt -jvm-target 25 -d jvm25
$ javap -v -cp jvm25 HelloKt | grep major
  major version: 69
$ kotlinc Hello.kt -jvm-target 26 -d jvm26
$ kotlinr -cp jvm25 HelloKt
Running on Java 25
$ kotlinr -cp jvm26 HelloKt
Exception in thread "main" java.lang.UnsupportedClassVersionError: HelloKt has been compiled by a more recent version of the Java Runtime (class file version 70.0), this version of the Java Runtime only recognizes class file versions up to 69.0
	at java.base/java.lang.ClassLoader.defineClass1(Native Method)
	at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:962)
	at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:144)
	at java.base/java.net.URLClassLoader.defineClass(URLClassLoader.java:454)
	at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:367)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:557)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:490)
[exit status 1]
$ export JAVA_HOME=…/java/temurin-27.0.0+35
$ kotlinr -cp jvm26 HelloKt
Running on Java 27
$ kotlinc Hello.kt -jvm-target 27 -d jvm27
error: unknown JVM target version: 27
Supported versions: 1.8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26
[exit status 1]

Recorded with Python 3.14.8 on macOS 26 arm64. To run it yourself: mise exec python@3.14.8 -- python3 target_session.py

The default build has version 52, the level of Java 8, so any JDK from 8 on can load it. -jvm-target 21 gave 65 and -jvm-target 25 gave 69. JDK 25 ran its own level, then refused the Java 26 build: “class file version 70.0 … only recognizes class file versions up to 69.0”, the limit the JVM specification sets for Java SE 25. JDK 27 ran the same classes.

Target levels in Kotlin 2.4.20

The levels a compiler accepts depend on its version. Kotlin 2.4.20 knows 1.8 and 9 to 26, so it refused -jvm-target 27 although JDK 27 is out and ran the Java 26 build; its error lists every level it accepts. Check that list for the compiler you use.

The table sums up the four builds:

-jvm-target Class-file version Runs on
1.8 (the default) 52 JDK 8 and newer
21 65 JDK 21 and newer
25 69 JDK 25 and newer
26 70 JDK 26 and newer: JDK 25 refused it, JDK 27 ran it

Key idea

Compile for the oldest JVM your code must run on: each JVM loads class files of its own level and below, and it stops the program with UnsupportedClassVersionError at start-up when a class is newer, long after the build passed.

Checkpoint

Check: Class-file versions and -jvm-target

  1. Question 1 of 2 Which class-file version did kotlinc 2.4.20 write when it was given no -jvm-target?

    Type a number.

    Show the answer: Question 1 of 2

    Answer: 52 class-file version

    The default -jvm-target is 1.8, Java 8's level, and javap showed major version 52. Any JDK from 8 on can load such classes.

  2. Question 2 of 2 Classes compiled with -jvm-target 26 are started on JDK 25. What happens?

    Choose one answer.

    Show the answer: Question 2 of 2

    Answer: The JVM refuses them with UnsupportedClassVersionError, because 70 is above its limit of 69

    -jvm-target 26 writes class-file version 70. JDK 25 recognises versions up to 69, so it throws UnsupportedClassVersionError when it loads the first class; JDK 27 ran the same classes.

Choose an editor that understands Kotlin

JetBrains provides official Kotlin support for two IDEs and one editor extension. IntelliJ IDEA bundles the Kotlin plugin with each release. Android Studio, the official IDE for Android apps, is based on IntelliJ IDEA and bundles the same plugin. For Visual Studio Code there is the official Kotlin by JetBrains extension, which gives completion, navigation, debugging and diagnostics through the Kotlin language server: A program that gives an editor completion, error messages and navigation for a language through the Language Server Protocol. JetBrains' Kotlin Language Server powers its Visual Studio Code extension., a server that is still in Alpha. Other editors can use that server through the Language Server Protocol, or community plugins.

The choice depends on what you build. The Language Server supports Gradle and Maven projects for the JVM, Android projects only experimentally, and no Kotlin Multiplatform projects yet; IntelliJ IDEA and Android Studio fully support them. Answer the three questions about your work:

Interactive · answer and compare Which editor fits your Kotlin work? Answer the three questions. The table marks the editors that fit and says why the others do not.
Will you build Android apps?
Must you stay in Visual Studio Code or another editor you already use?
Is it a Kotlin Multiplatform project?

Answer the questions above: the table then marks what fits your case and says why the rest does not.

Four ways to edit Kotlin, against official support, build systems and Multiplatform projects
Editor Official Kotlin support Build systems Multiplatform projects
IntelliJ IDEA Support comes from: the Kotlin plugin bundled with each release Good official, bundled with each IntelliJ IDEA release Good Gradle and Maven projects Good Multiplatform projects are fully supported
Android Studio Support comes from: the same plugin; the IDE is based on IntelliJ IDEA Good official: the IDE for Android apps, Kotlin bundled Good Gradle with the Android Gradle plugin Good Multiplatform projects are fully supported
Visual Studio Code Support comes from: the Kotlin by JetBrains extension, on the Kotlin Language Server Mixed official extension, but the Language Server is in Alpha Mixed Gradle and Maven for the JVM; Android support experimental Poor Multiplatform support is still under development
Another editor with LSP Support comes from: the Kotlin Language Server or a community plugin Mixed the Language Server works with any LSP editor; no official plugin Mixed what the Language Server supports, nothing more Poor Multiplatform support is still under development
How the answers decide
  • “Will you build Android apps?” Yes, Android apps: adds a caveat to IntelliJ IDEA, Visual Studio Code and Another editor with LSP. Android Studio is the official IDE for Android apps; the Language Server's Android support is still experimental.
  • “Must you stay in Visual Studio Code or another editor you already use?” Yes, my editor stays: rules out IntelliJ IDEA and Android Studio and adds a caveat to Visual Studio Code and Another editor with LSP. Staying in your editor means the Kotlin Language Server, which is in Alpha, so expect gaps and report them.
  • “Is it a Kotlin Multiplatform project?” Yes, several targets: rules out Visual Studio Code and Another editor with LSP. The Kotlin Language Server does not support Multiplatform projects yet; IntelliJ IDEA and Android Studio do.

In short: Android Studio for Android apps, IntelliJ IDEA for everything else, and Visual Studio Code with the Kotlin extension when you must keep your editor and your project is a JVM project. Every lesson of this track works with any of them, because each program is a file you compile and run from a terminal.

Checkpoint

Check: Choosing an editor for Kotlin

  1. One question Which of these setups does not support a Kotlin Multiplatform project yet?

    Choose one answer.

    Show the answer: One question

    Answer: Visual Studio Code with the Kotlin by JetBrains extension

    IntelliJ IDEA and Android Studio fully support Kotlin Multiplatform. The Kotlin Language Server, behind the Visual Studio Code extension, is in Alpha and supports JVM projects; Multiplatform support is still being built.

Pin the versions in files the project keeps

The terminal, the editor and a CI machine can each run a different kotlinc on a different JDK, and then the same code behaves differently in each. The cure is to write the versions into files that are committed with the project. A version manager reads them when you enter the project’s folder. With mise, mise use kotlin@2.4.20 and mise use java@temurin-25.0.4+101.0.LTS write this file:

mise.toml TOML · pin/mise.toml
[tools]
java = "temurin-25.0.4+101.0.LTS"
kotlin = "2.4.20"

Teammates and CI then run mise install to get exactly these tools, mise exec -- kotlinc -version runs a command with them, and with mise activated in your shell, entering the folder puts them on your PATH. Write full versions, as here: a short version such as "25" is a prefix that different computers may resolve to different builds. With SDKMAN, the same pins live in a file named .sdkmanrc with one line per tool, java=25.0.4.1+1-tem and kotlin=2.4.20; sdk env install installs what is missing and sdk env switches the shell to them.

Each file pins what one tool reads, and together they leave nothing to chance:

File Pins Read by
mise.toml kotlinc 2.4.20 and the JDK on your PATH mise, when you enter the folder
.sdkmanrc the same two, as SDKMAN names them sdk env
build.gradle.kts the project’s Kotlin and the JDK it is built against Gradle, on every build
gradle/wrapper/gradle-wrapper.properties the Gradle version ./gradlew

A Gradle build pins both again for itself, which the lesson after next shows: the Kotlin version is the version of the Kotlin Gradle plugin, and jvmToolchain(25) names the JDK the build compiles against and tests on, independent of the JDK in your terminal. JetBrains is also building the Kotlin Toolchain, a new, declarative entry point that is still in Alpha; it has a kotlin command of its own, which is why the runner of Kotlin 2.4.20 is called kotlinr.

Checkpoint

Check: Pinning versions per project

  1. One question A project's mise.toml says java = "25", and two laptops still run different JDK builds. Why?

    Choose one answer.

    Show the answer: One question

    Answer: "25" is a prefix, so each computer may resolve it to a different 25.x build

    A version manager installs what the file names. "25" names a family of builds, and the newest one a computer sees can differ; a full version names exactly one, so every machine runs the same JDK.

Practise: read a version line

The program below should read the two versions out of a line of kotlinc -version. As given, it returns null for every line, so only the check for a line that is not a version line passes, and the program ends with status 1:

Version.kt, before you start Kotlin · version/Version.kt
// Practice: read the compiler's version and the JRE it runs on out of one line of kotlinc -version.
fun parseKotlincVersion(line: String): Pair<String, String>? {
    // Replace this line: return the two versions, or null when the line is not a kotlinc -version line.
    return null
}

fun main() {
    val cases =
        listOf(
            "info: kotlinc-jvm 2.4.20 (JRE 25.0.4.1+1-LTS)" to ("2.4.20" to "25.0.4.1+1-LTS"),
            "info: kotlinc-jvm 2.4.20 (JRE 27+35)" to ("2.4.20" to "27+35"),
            "info: kotlinc-jvm 2.3.21 (JRE 21.0.12.1+1-LTS)" to ("2.3.21" to "21.0.12.1+1-LTS"),
            "kotlinc: command not found" to null,
        )
    var failed = 0
    for ((line, expected) in cases) {
        val actual = parseKotlincVersion(line)
        if (actual != expected) failed++
        val mark = if (actual == expected) "ok  " else "FAIL"
        println("$mark \"$line\" -> $actual")
    }
    println("${cases.size - failed} of ${cases.size} checks pass")
    if (failed > 0) kotlin.system.exitProcess(1)
}

Output (exit status 1)

FAIL "info: kotlinc-jvm 2.4.20 (JRE 25.0.4.1+1-LTS)" -> null
FAIL "info: kotlinc-jvm 2.4.20 (JRE 27+35)" -> null
FAIL "info: kotlinc-jvm 2.3.21 (JRE 21.0.12.1+1-LTS)" -> null
ok   "kotlinc: command not found" -> null
1 of 4 checks pass

Recorded with Kotlin 2.4.20 on OpenJDK 25.0.4.1 LTS (Eclipse Temurin) on macOS 26 arm64. To run it yourself: kotlinc Version.kt -include-runtime -d main.jar && java -jar main.jar

Copy it, write parseKotlincVersion, and run it with kotlinc Version.kt -include-runtime -d version.jar && java -jar version.jar until all four checks pass. First hint: the compiler’s version follows kotlinc-jvm , and the JRE’s sits between (JRE and ); substringAfter and substringBefore find both, but check first that the line has these parts at all.

Twelve short questions follow, on installing, JVM levels, editors and pins. They begin with whatever you answer least well, and every choice explains itself:

Practice that adapts to you

Practise this lesson

12 questions about 4 ideas of this lesson. Each answer is explained at once, and what you get right is kept in this browser.

  1. Question 1 of 12 Which way of installing kotlinc does the Kotlin documentation recommend on Windows?

    Choose one answer.

    Show the answer: Question 1 of 12

    Answer: Downloading the compiler zip from GitHub and adding kotlinc/bin to the PATH

    The zip from the GitHub release works on every system, and on Windows the documentation recommends it. SDKMAN, Homebrew and Snap are the alternatives on Unix-like systems.

  2. Question 2 of 12 You need exactly Kotlin 2.4.20 from a package manager. Which command installs it?

    Choose one answer.

    Show the answer: Question 2 of 12

    Answer: sdk install kotlin 2.4.20

    SDKMAN takes a version: sdk install kotlin 2.4.20. Homebrew's and Snap's commands of the documentation name none, so they install the version the package is at.

  3. Question 3 of 12 JAVA_HOME is not set. Which java does kotlinc run on?

    Choose one answer.

    Show the answer: Question 3 of 12

    Answer: The first java on the PATH

    kotlinc uses $JAVA_HOME/bin/java when JAVA_HOME is set, and otherwise the java the PATH finds. kotlinc -version then names that runtime in brackets.

  4. Question 4 of 12 Which class-file version did -jvm-target 25 give in the session?

    Type a number.

    Show the answer: Question 4 of 12

    Answer: 69 class-file version

    javap printed major version 69 for -jvm-target 25, the highest version a Java SE 25 JVM supports.

  5. Question 5 of 12 What does kotlinc 2.4.20 do with -jvm-target 27?

    Choose one answer.

    Show the answer: Question 5 of 12

    Answer: It stops with "unknown JVM target version: 27" and lists the versions it supports

    Kotlin 2.4.20 accepts 1.8 and 9 to 26. Asking for 27 stops with an error that lists the supported versions.

  6. Question 6 of 12 A service runs on JDK 21 in production and on JDK 25 on the developers' laptops. Which -jvm-target keeps it starting everywhere?

    Choose one answer.

    Show the answer: Question 6 of 12

    Answer: 21

    Target the oldest JVM the code must run on, here JDK 21. Its class-file version, 65, loads on every newer JVM.

  7. Question 7 of 12 Which IDE is the official IDE for Android app development?

    Choose one answer.

    Show the answer: Question 7 of 12

    Answer: Android Studio

    Android Studio is the official IDE for Android app development. It is based on IntelliJ IDEA and bundles the Kotlin plugin with each release.

  8. Question 8 of 12 What stage is the Kotlin Language Server at, and what does that mean for a team that adopts it?

    Choose one answer.

    Show the answer: Question 8 of 12

    Answer: Alpha: it works, is under active development, and may have gaps or change

    The Kotlin Language Server is JetBrains' official LSP implementation for Kotlin, in Alpha. It supports Gradle and Maven JVM projects, with Android support experimental and Multiplatform support still under development.

  9. Question 9 of 12 A team keeps Visual Studio Code and builds a JVM service with Gradle. What do they install, and what should they expect?

    Choose one answer.

    Show the answer: Question 9 of 12

    Answer: The Kotlin by JetBrains extension; Gradle JVM projects work, but the Language Server is in Alpha

    For a JVM service built with Gradle, Visual Studio Code with the Kotlin by JetBrains extension fits. The team should expect Alpha-stage gaps, and move Multiplatform work to IntelliJ IDEA or Android Studio.

  10. Question 10 of 12 You clone a project with a mise.toml. Which command installs the tools it pins?

    Choose one answer.

    Show the answer: Question 10 of 12

    Answer: mise install

    mise use writes pins into mise.toml, and mise install installs everything the file lists, so every computer ends up with the same versions.

  11. Question 11 of 12 A project has an .sdkmanrc with java=25.0.4.1+1-tem and kotlin=2.4.20, and both are installed. Which command switches your shell to them?

    Choose one answer.

    Show the answer: Question 11 of 12

    Answer: sdk env

    SDKMAN keeps project pins in .sdkmanrc, one tool a line. sdk env install installs what is missing, and sdk env switches the current shell to the pinned versions.

  12. Question 12 of 12 A project builds with Gradle and also has a mise.toml. In CI, what decides the JDK that the code is compiled against and tested on?

    Choose one answer.

    Show the answer: Question 12 of 12

    Answer: The Gradle build, through jvmToolchain(25), whichever JDK runs Gradle

    A Gradle build pins its own toolchain: the Kotlin Gradle plugin's version is the Kotlin version, and jvmToolchain names the JDK the code is compiled against and tested on. Version-manager files pin what the terminal runs, including the JDK that starts Gradle.

Interview questions

These three follow-up questions are the kind an interviewer asks after “how do you set up Kotlin?”. Each answer explains itself as soon as you check it:

Checkpoint

Interview round: three follow-up questions

  1. Question 1 of 3 A service passes in CI and then fails at start-up in production with "class file version 69.0 … only recognizes class file versions up to 65.0". Which JDK does production run?

    Choose one answer.

    Show the answer: Question 1 of 3

    Answer: JDK 21, whose limit is class-file version 65

    The first number is the class files' version and the second the JVM's limit. 69 is Java 25's level and 65 Java 21's, so the build targeted 25 while production runs JDK 21.

  2. Question 2 of 3 kotlinc -version prints 2.4.21 on one teammate's laptop and 2.4.20 on another. What do you do first to make them agree?

    Choose one answer.

    Show the answer: Question 2 of 3

    Answer: Pin the full Kotlin version in a file committed with the project, and install from it on both laptops

    The difference comes from how each laptop installed Kotlin. Writing the version into a committed file and installing from it, with mise or SDKMAN, removes the difference on every computer and in CI.

  3. Question 3 of 3 The users of your library run JDK 17, 21 and 25. Which -jvm-target do you compile it with?

    Choose one answer.

    Show the answer: Question 3 of 3

    Answer: 17, the oldest JVM it must run on

    A JVM runs class files up to its own version, so a library targets the oldest JVM among its users. Its classes then load on every newer JDK.

Model answers open with any pass: ₹79 for 1 week ($2.99), one payment that never renews.

  1. Fresher to mid

    A Kotlin service builds and passes its tests in CI, but in production it fails at start-up with UnsupportedClassVersionError: class file version 69.0, while the runtime only recognizes versions up to 65.0. Explain the message and give two fixes, with their costs.

    Model answer, Pro. Model answers open with any pass; prices are in the notice on this page. First step and follow-ups

  2. Fresher to mid

    On one laptop kotlinc -version prints 2.4.21 with JRE 21.0.12.1+1-LTS; on another it prints 2.4.20 with JRE 25.0.4.1+1-LTS, and CI builds with Gradle. Small programs behave differently on the two laptops. Explain where the difference can come from and how you make every machine use the same toolchain.

    Model answer, Pro. First step and follow-ups

Key takeaways

  • kotlinc runs on a JVM, so a JDK comes first; check both installs with java -version and kotlinc -version, whose brackets name the Java runtime the compiler runs on.
  • kotlinc and kotlinr take their JVM from JAVA_HOME when it is set and from the first java on the PATH otherwise, so the same command reported JRE 25 and then JRE 27.
  • -jvm-target sets the class-file version, 52 by default, 65 for 21, 69 for 25 and 70 for 26, and a JVM refuses any version above its own with UnsupportedClassVersionError.
  • IntelliJ IDEA and Android Studio bundle the Kotlin plugin; Visual Studio Code uses the Alpha Kotlin Language Server, which supports JVM projects but not yet Multiplatform ones.
  • Pin full versions in a file committed with the project, mise.toml or .sdkmanrc, so terminals, editors and CI run the same toolchain; a Gradle build pins its own Kotlin version and JDK as well.

Terms in this lesson

-jvm-target
The kotlinc option that sets the bytecode level of the class files it writes: 1.8 by default, and 9 to 26 in Kotlin 2.4.20. A JVM runs class files up to its own level only.
class-file version
The number in a .class file that says which Java version's bytecode it holds: 52 for Java 8, 69 for Java 25 and 70 for Java 26. A JVM refuses a number above its own.
JAVA_HOME
An environment variable that names the folder of a JDK, the one that holds bin. kotlinc and kotlinr run on the java of the JDK it names, before any java on the PATH.
JDK
The Java Development Kit: a JVM together with tools such as javac and javap. kotlinc is itself a JVM program, so it needs a JDK to run as well as to run what it compiles.
language server
A program that gives an editor completion, error messages and navigation for a language through the Language Server Protocol. JetBrains' Kotlin Language Server powers its Visual Studio Code extension.

References

Report a problem with this lesson

Quick answers and tool search

Type to search tools or to get a quick answer, for example 18% of 2500. Use the up and down arrow keys to move through the results, Enter to choose, and Escape to close.