Kotlin is a statically typed programming language developed by JetBrains that runs on the Java Virtual Machine (JVM), compiles to JavaScript, and targets native binaries. Google designated it the preferred language for Android development, and it has since expanded into server-side frameworks like Ktor and Spring Boot, multiplatform mobile development, and data engineering pipelines. Its interoperability with Java means you can use existing Java libraries directly, while features like null safety, coroutines, and extension functions reduce boilerplate and common runtime errors. This guide shows how to install Kotlin on Arch Linux using the official repositories, set up the compiler and script runner, and verify the toolchain with a working Hello World program.
Update Arch Linux Before Kotlin Installation
Synchronize package databases and upgrade installed packages before installing new software. Arch Linux is a rolling release distribution, so regular updates prevent dependency conflicts:
sudo pacman -Syu
This guide uses
sudofor commands 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 on Arch Linux via pacman
The kotlin package is available in the official Arch Linux extra repository. It includes the Kotlin compiler (kotlinc), the Kotlin script runner (kotlin), and the JVM-targeting compiler (kotlinc-jvm). The package automatically pulls in a Java runtime as a dependency because Kotlin compiles to JVM bytecode.
Install the Kotlin Package
Install Kotlin using pacman:
sudo pacman -S kotlin
Pacman resolves and installs the java-runtime-headless dependency automatically. On a fresh system, this pulls in jdk-openjdk, which provides both the Java Runtime Environment and the Java Development Kit needed to compile and run Kotlin programs.
Verify the Kotlin Installation
Confirm Kotlin is installed and check the compiler version:
kotlinc -version
Expected output:
info: kotlinc-jvm 2.3.0 (JRE 25.0.2)
Check the Kotlin runtime version:
kotlin -version
Kotlin version 2.3.0-release-356 (JRE 25.0.2)
Verify the Java runtime that Kotlin depends on:
java --version
openjdk 25.0.2 2026-01-20 OpenJDK Runtime Environment (build 25.0.2) OpenJDK 64-Bit Server VM (build 25.0.2, mixed mode, sharing)
Verify the installation path using command -v (the which utility is not installed by default on minimal Arch systems):
command -v kotlinc
/usr/bin/kotlinc
Create and Run a Kotlin Program on Arch Linux
Verify that the Kotlin toolchain can compile and execute programs by building a simple test application. Kotlin supports three execution methods: compiling to a standalone JAR, running scripts directly, and using the interactive REPL shell.
Compile and Run a Kotlin Application
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.
Compile the Kotlin source file into a standalone 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, making it portable to any system with a Java runtime. The -d flag specifies the output file.
Run the compiled program:
java -jar hello.jar
Expected output:
Hello, Kotlin on Arch Linux! Kotlin version: 2.3.0 JVM version: 25.0.2
Run a Kotlin Script
Kotlin scripts (.kts files) run directly without a separate compilation step, which is useful for automation tasks, build scripts, and quick prototyping. Create a script file:
nano hello.kts
Add the following:
val os = System.getProperty("os.name")
val arch = System.getProperty("os.arch")
println("Running Kotlin script on $os ($arch)")
Save and exit, then run the script:
kotlin hello.kts
Running Kotlin script on Linux (amd64)
Use the Kotlin Interactive REPL
The Kotlin compiler includes an interactive REPL (Read-Eval-Print Loop) for testing expressions, exploring APIs, and quick calculations. Launch it by running kotlinc with no arguments:
kotlinc
Welcome to Kotlin version 2.3.0 (JRE 25.0.2) Type :help for help, :quit for quit >>>
Try a quick expression to confirm it works, then exit with :quit or Ctrl+D:
>>> println("Kotlin REPL is working")
>>> :quit
Install Kotlin Development Tools on Arch Linux
The base kotlin package provides the compiler and runtime. Additional tools improve the development workflow for larger projects.
Install ktlint for Code Linting
ktlint is an anti-bikeshedding Kotlin linter and formatter that enforces the Kotlin coding conventions and the Android Kotlin style guide. It is available in the official Arch Linux repositories:
sudo pacman -S ktlint
Verify the installation:
ktlint --version
ktlint version 1.8.0
Run ktlint against your Kotlin source files to check for style violations:
ktlint hello.kt
ktlint reports a filename convention warning because hello.kt does not use PascalCase naming. This is expected for a test file and does not affect compilation or execution.
To automatically fix formatting issues, use the --format flag:
ktlint --format hello.kt
Filename issues cannot be auto-corrected by the formatter. For production projects, name files using PascalCase (for example, Hello.kt) to satisfy this convention.
Set Up Gradle for Kotlin Projects (Optional)
For multi-file projects and dependency management, Gradle is the standard build tool for Kotlin development. It handles compilation, testing, dependency resolution, and packaging. Install Gradle from the official repositories:
sudo pacman -S gradle
Initialize a new Kotlin project with Gradle:
mkdir ~/kotlin-project && cd ~/kotlin-project
gradle init --type kotlin-application --dsl kotlin
Gradle prompts for project settings during initialization. Accept the defaults to generate a standard Kotlin project with a build.gradle.kts build script, source directories, and test scaffolding.
Build and run the generated project:
gradle run
Expected output (the first run includes a compilation step):
> Task :app:run Hello World! BUILD SUCCESSFUL
Troubleshoot Kotlin on Arch Linux
kotlinc Fails with “No JDK Found”
Error: Running kotlinc produces an error about a missing JDK or JAVA_HOME not being set.
Cause: The Java runtime was not installed or the JAVA_HOME environment variable is not configured. This can happen if you removed the JDK or if multiple Java versions are installed and none is set as default.
Fix: Install the default OpenJDK and set the Java environment:
sudo pacman -S jdk-openjdk
Verify Java is available:
java --version
If multiple Java versions are installed, use Arch Linux’s archlinux-java utility to set the active version:
archlinux-java status
sudo archlinux-java set java-25-openjdk
Compilation Produces OutOfMemoryError
Error: Compiling large projects with kotlinc fails with java.lang.OutOfMemoryError: Java heap space.
Cause: The default JVM heap size is insufficient for large Kotlin projects. The Kotlin compiler runs on the JVM and inherits its default memory settings.
Fix: Increase the JVM heap size by setting the JAVA_OPTS environment variable before compiling:
export JAVA_OPTS="-Xmx2g"
kotlinc hello.kt -include-runtime -d hello.jar
To make this permanent, add the export to your shell configuration file (~/.bashrc or ~/.zshrc) and restart your shell or run source ~/.bashrc.
Kotlin Version Mismatch After System Update
Error: After a system update, compiled JAR files fail with UnsupportedClassVersionError or metadata compatibility warnings.
Cause: Arch Linux is a rolling release distribution, so pacman -Syu can update both Kotlin and the JDK simultaneously. JAR files compiled with a newer JDK target version cannot run on an older JVM.
Fix: Recompile your projects after major Kotlin or JDK updates:
kotlinc hello.kt -include-runtime -d hello.jar
Check the current Kotlin and Java versions to confirm they are aligned:
kotlinc -version
java --version
Remove Kotlin from Arch Linux
To remove Kotlin and its orphaned dependencies:
sudo pacman -Rns kotlin
The -Rns flags remove the package (-R), orphaned dependencies (-s), and configuration backup files (-n).
The
-sflag removes dependencies that were installed only for Kotlin and are not required by any other package. If the JDK was installed solely as a Kotlin dependency, it will be removed as well. Check what will be removed withpacman -Rns kotlin --printbefore confirming.
If you installed additional Kotlin-related packages, remove them explicitly:
sudo pacman -Rns ktlint gradle
Verify removal:
pacman -Qi kotlin
error: package 'kotlin' was not found
Clean up any compiled files or project directories you no longer need:
rm -f hello.kt hello.kts hello.jar
rm -rf ~/kotlin-project
Frequently Asked Questions About Kotlin on Arch Linux
Yes. Kotlin compiles to JVM bytecode and requires a Java runtime to execute. The kotlin package in the Arch Linux repositories lists java-runtime-headless as a dependency, which pacman installs automatically. On a fresh system this pulls in jdk-openjdk.
kotlinc is the Kotlin compiler that compiles .kt source files into JVM bytecode (JAR files). kotlin is the runtime tool that executes compiled programs and can also run .kts script files directly without a separate compilation step. Both commands are installed by the kotlin package.
Yes. Install Android Studio from the AUR, which bundles its own Kotlin plugin and build tools. The system-level kotlin package installed via pacman is useful for server-side and command-line Kotlin development, while Android Studio manages its own Kotlin compiler version for Android projects.
Kotlin updates arrive through regular system updates. Run sudo pacman -Syu to synchronize repositories and upgrade all packages including Kotlin. To update only the Kotlin package, run sudo pacman -S kotlin.
Conclusion: Kotlin on Arch Linux
You now have Kotlin installed on Arch Linux with the compiler, script runner, and interactive REPL ready for development. The JDK dependency was resolved automatically, and the Hello World test confirms the complete toolchain works from source compilation through execution. For backend development, pair Kotlin with PostgreSQL or MariaDB on Arch Linux. To containerize Kotlin applications, follow the guide on installing Docker on Arch Linux. For language reference, tutorials, and framework documentation, refer to the official Kotlin documentation.
Formatting tips for your comment
You can use basic HTML to format your comment. Useful tags currently allowed:
<code>command</code>command<strong>bold</strong><em>italic</em><blockquote>quote</blockquote>