How to Install Kotlin on Arch Linux

Install Kotlin on Arch Linux with pacman. Includes compiler setup, Hello World verification, ktlint, Gradle, and troubleshooting.

Last updatedAuthorJoshua JamesRead time5 minGuide typeArch Linux

Kotlin projects on Arch usually need two things before the first compile works: the Kotlin command-line tools and a Java runtime that matches the JVM target. You can install Kotlin on Arch Linux from the official extra repository, then use kotlinc, kotlin, and Java together for scripts, standalone JAR files, and Gradle-based projects.

The Arch package installs the system Kotlin compiler and script runner. Android Studio and Gradle projects may still use a project-managed Kotlin plugin version, so treat the system package as the local command-line toolchain rather than a replacement for every build-file setting.

Install Kotlin on Arch Linux

Start by synchronizing package databases and upgrading installed packages. Arch is a rolling release distribution, so updating first prevents partial-upgrade dependency problems:

sudo pacman -Syu

These commands use sudo for tasks that need root privileges. If your user is not in the sudoers file yet, run the commands as root or follow the guide on how to add and manage sudo users on Arch Linux.

Install Kotlin and OpenJDK with pacman

Install the official Arch Kotlin package with the current OpenJDK package. Adding jdk-openjdk explicitly avoids the Java provider prompt that appears on clean systems when Pacman only sees Kotlin’s virtual java-runtime-headless dependency:

sudo pacman -S kotlin jdk-openjdk

If you already have another OpenJDK branch installed and selected with Arch’s Java tools, Pacman can satisfy Kotlin’s Java dependency with that provider. For a new development setup, jdk-openjdk gives you the current runtime and full Java development kit in one package.

Verify Kotlin and Java on Arch Linux

Check the Kotlin compiler version:

kotlinc -version

Arch package versions move forward over time. Current output starts with a kotlinc-jvm line similar to this:

info: kotlinc-jvm 2.3.21 (JRE 26.0.1)

Confirm the Kotlin runtime command as well:

kotlin -version
Kotlin version 2.3.21-release-298 (JRE 26.0.1)

Verify Java is active:

java --version
openjdk 26.0.1 2026-04-21
OpenJDK Runtime Environment (build 26.0.1)
OpenJDK 64-Bit Server VM (build 26.0.1, mixed mode, sharing)

Confirm which package owns the Kotlin command-line tools:

command -v kotlinc
pacman -Qo /usr/bin/kotlinc /usr/bin/kotlin

Relevant output includes:

/usr/bin/kotlinc
/usr/bin/kotlinc is owned by kotlin 2.3.21-1
/usr/bin/kotlin is owned by kotlin 2.3.21-1

Compile and Run Kotlin on Arch Linux

A small source file verifies more than package presence. It proves the Kotlin compiler can produce a runnable JVM artifact and that Java can execute it.

Create a Kotlin Source File

Create a file named hello.kt:

nano hello.kt

Add the following Kotlin code:

fun main() {
    println("Hello, Kotlin on Arch Linux!")
    println("Kotlin version: ${KotlinVersion.CURRENT}")
    println("JVM version: ${System.getProperty("java.version")}")
}

Save the file with Ctrl+O, press Enter, then exit with Ctrl+X.

Build and Run a Kotlin JAR

Compile the Kotlin source file into a runnable JAR that includes the Kotlin runtime:

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

The -include-runtime flag bundles the Kotlin standard library into the JAR, and -d sets the output filename. Run the compiled program with Java:

java -jar hello.jar
Hello, Kotlin on Arch Linux!
Kotlin version: 2.3.21
JVM version: 26.0.1

Run a Kotlin Script

Kotlin scripts use the .kts extension and run without a separate manual compile step. Create a script file:

nano hello.kts

Add the following script:

val os = System.getProperty("os.name")
val arch = System.getProperty("os.arch")
println("Running Kotlin script on $os ($arch)")

Save the file, then run it with the kotlin command:

kotlin hello.kts
Running Kotlin script on Linux (amd64)

Add Kotlin Development Tools on Arch Linux

The base Kotlin package is enough for compiler and script work. Add these tools when you need formatting, project scaffolding, dependency resolution, or Android-oriented workflows.

Install ktlint for Kotlin Formatting

ktlint checks and formats Kotlin code against the Kotlin coding conventions. Install the official Arch package when you want a local formatter outside an IDE:

sudo pacman -S ktlint

Verify the formatter command:

ktlint --version
ktlint version 1.8.0

Run ktlint against the sample source file:

ktlint hello.kt

A lowercase test filename may trigger a filename convention warning. For real projects, name source files with PascalCase, such as Hello.kt, when the file declares a matching type or top-level entry point.

Format files automatically when the reported issue can be corrected safely:

ktlint --format hello.kt

Create a Kotlin Project with Gradle

Gradle is the usual build tool for multi-file Kotlin projects. The Arch gradle package depends on a full Java environment, so the earlier jdk-openjdk install also supports this workflow:

sudo pacman -S gradle

Create a small Kotlin application project:

mkdir ~/kotlin-project && cd ~/kotlin-project
gradle init --type kotlin-application --dsl kotlin --test-framework junit-jupiter --project-name kotlin-project --package org.example

Successful initialization ends with:

> Task :init
BUILD SUCCESSFUL

Run the generated application with the Gradle wrapper. The first run may download the wrapper distribution before compiling the sample app:

./gradlew run

Relevant output includes:

> Task :app:run
Hello World!

BUILD SUCCESSFUL

Understand Kotlin, Gradle, and Android Studio Version Ownership

The Arch kotlin package owns /usr/bin/kotlinc and /usr/bin/kotlin. Gradle projects usually choose their Kotlin version through the Kotlin Gradle plugin in the project files, and Android Studio manages its own Kotlin plugin and Android toolchain. If a project builds through Gradle or Android Studio, check that project’s plugin version before assuming it is using the system kotlinc command.

For version planning, Kotlin’s release process is organized around language, tooling, and bug-fix releases. Arch exposes the current packaged compiler, while project builds should pin the Kotlin plugin version they require.

Update Kotlin on Arch Linux

Kotlin, OpenJDK, ktlint, and Gradle update through normal Arch system upgrades. Use a full system update instead of trying to hold only one JVM package back:

sudo pacman -Syu

After major Kotlin or Java updates, rebuild project artifacts that you compiled locally. This prevents old JAR files from carrying stale bytecode or metadata assumptions into a newer toolchain.

Troubleshoot Kotlin on Arch Linux

kotlinc Command Not Found

If the shell cannot find kotlinc, first verify whether the package is installed:

pacman -Q kotlin
kotlin 2.3.21-1

If Pacman reports that the package is missing, install Kotlin and the current OpenJDK package again:

sudo pacman -S kotlin jdk-openjdk

Then confirm the command path:

command -v kotlinc
/usr/bin/kotlinc

Java or JNI Version Errors

Errors such as A JNI error has occurred, please check your installation and try again or UnsupportedClassVersionError usually mean the selected Java runtime is older than the bytecode target used by the compiled program.

Check the active Java runtime and Arch’s Java environment selection:

java --version
archlinux-java status

Relevant output includes:

openjdk 26.0.1 2026-04-21
Available Java environments:
  java-26-openjdk (default)

If no suitable OpenJDK environment is installed, install the current JDK package:

sudo pacman -S jdk-openjdk

If several Java branches are installed, use the environment name shown by archlinux-java status. For example, the current OpenJDK package appears as java-26-openjdk:

sudo archlinux-java set java-26-openjdk

Recompile the Kotlin source after changing Java versions:

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

Gradle Uses a Different Kotlin Version

If kotlinc -version shows one Kotlin version but a Gradle build downloads or reports another, the project is probably using the Kotlin Gradle plugin declared in build.gradle.kts. That is normal for project builds because Gradle resolves the compiler plugin from the project configuration, not from /usr/bin/kotlinc.

Use the grep command in Linux to check the generated Gradle project files for the plugin version:

grep -R -E "org\.jetbrains\.kotlin|kotlin-jvm|plugins\.kotlin" app/build.gradle.kts gradle/libs.versions.toml

Relevant output includes the plugin alias and version catalog entry:

app/build.gradle.kts:    alias(libs.plugins.kotlin.jvm)
gradle/libs.versions.toml:kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version = "2.3.20" }

Keep the project-managed plugin version unless the project documentation or build error tells you to change it. Updating the Arch kotlin package only changes the system compiler and script runner.

Remove Kotlin from Arch Linux

Preview what Pacman would remove before deleting Kotlin. The preview omits -n because Pacman does not combine --print with the --nosave cleanup flag:

sudo pacman -Rs kotlin --print

If the removal list looks correct, remove the Kotlin package:

sudo pacman -Rns kotlin

If you installed ktlint or Gradle above, remove those optional packages separately:

sudo pacman -Rns ktlint gradle

Keep jdk-openjdk if other Java applications, IDEs, or build tools use it. Remove it only when you installed it solely for this Kotlin setup:

sudo pacman -Rns jdk-openjdk

Verify Kotlin is no longer installed:

pacman -Q kotlin || echo "kotlin is not installed"
error: package 'kotlin' was not found
kotlin is not installed

The following cleanup commands permanently delete the sample files and Gradle project created during the sample workflow. Do not run them inside a real project directory unless you have backed up anything you need.

rm -f hello.kt hello.kts hello.jar
rm -rf ~/kotlin-project

Conclusion

Kotlin is ready on Arch with the system compiler, script runner, Java runtime, and optional Gradle or ktlint workflow in place. For backend work, install PostgreSQL on Arch Linux or install MariaDB on Arch Linux; containerized Kotlin services pair naturally after you install Docker on Arch Linux.

Share this guide

Help another Linux user troubleshoot faster

Share this guide with someone troubleshooting Linux systems or saving it for later.

Follow LinuxCapable

Want more LinuxCapable guides in Google?

Add LinuxCapable as a preferred source so Google can show more of our fresh Linux tutorials in Top Stories and From your sources when relevant.

Add LinuxCapable as a preferred source on Google
Search LinuxCapable

Need another guide?

Search LinuxCapable for package installs, commands, troubleshooting, and follow-up guides related to what you just read.

Found this guide useful?

Support LinuxCapable to keep tutorials free and up to date.

Buy me a coffeeBuy me a coffee
Before commenting, please review our Comments Policy.
Formatting tips for your comment

You can use basic HTML to format your comment. Useful tags currently allowed in published comments:

You type Result
<code>command</code> command
<strong>bold</strong> bold
<em>italic</em> italic
<blockquote>quote</blockquote> quote block

Got a Question or Feedback?

We read and reply to every comment - let us know how we can help or improve this guide.

Verify before posting: