How To Install Kotlin on Rocky Linux 10

Kotlin has emerged as one of the most versatile programming languages in modern software development. Created by JetBrains, this statically-typed language combines concise syntax with powerful features that make coding more efficient and enjoyable. Whether you’re building Android applications, server-side systems, or multiplatform projects, Kotlin delivers exceptional performance on the Java Virtual Machine.
Rocky Linux 10 provides the perfect foundation for Kotlin development. As a community-driven, enterprise-grade operating system and direct successor to CentOS, Rocky Linux offers stability, security, and long-term support that developers need. This comprehensive guide walks you through multiple installation methods, helping you set up a complete Kotlin development environment on Rocky Linux 10.
By the end of this tutorial, you’ll have Kotlin installed, configured, and ready for development. Let’s get started.
Understanding Kotlin and Rocky Linux 10
What is Kotlin?
Kotlin launched in 2011 as JetBrains’ answer to Java’s verbosity and complexity. The language gained massive traction when Google announced it as an official Android development language in 2017. Today, companies like Netflix, Uber, and Pinterest rely on Kotlin for critical applications.
The language shines through its null safety features, which eliminate the dreaded NullPointerException errors that plague Java developers. Full interoperability with Java means you can use existing Java libraries seamlessly. Kotlin’s concise syntax reduces boilerplate code by up to 40% compared to Java, accelerating development cycles significantly.
Why Rocky Linux 10?
Rocky Linux emerged as the community’s response when Red Hat discontinued CentOS. Built from Red Hat Enterprise Linux (RHEL) source code, Rocky Linux delivers binary compatibility and enterprise-level reliability without licensing costs.
The DNF package manager in Rocky Linux 10 streamlines software management with improved dependency resolution and faster performance. For developers, this translates to easier environment setup and maintenance. The platform’s stability makes it ideal for production Kotlin deployments where uptime matters.
Prerequisites and System Requirements
Before installing Kotlin on Rocky Linux 10, ensure your system meets these requirements:
- Root or sudo privileges for package installation
- At least 2GB RAM (4GB recommended for development)
- 5GB free disk space
- Active internet connection
- Rocky Linux 10 (any edition)
- Basic familiarity with terminal commands
Most importantly, Kotlin requires the Java Development Kit (JDK) since it compiles to Java bytecode and runs on the JVM. We’ll install this as part of the setup process.
Pre-Installation Steps
Update System Packages
Start by updating your Rocky Linux system to ensure all packages are current. This prevents compatibility issues and security vulnerabilities.
Open your terminal and run:
sudo dnf update -y
The -y flag automatically confirms all prompts. This command updates package repositories and upgrades installed software. Depending on your system’s current state, this may take several minutes.
Verify your Rocky Linux version:
cat /etc/rocky-release
You should see output confirming Rocky Linux 10.
Install Required Dependencies
Kotlin installation requires several essential packages. Install curl, unzip, and zip utilities first:
sudo dnf install curl unzip zip -y
These tools handle downloads and archive extraction during installation.
Next, install the Java Development Kit. OpenJDK 17 provides excellent Kotlin compatibility:
sudo dnf install java-17-openjdk java-17-openjdk-devel -y
The java-17-openjdk package provides the Java runtime, while java-17-openjdk-devel includes the compiler and development tools necessary for Kotlin.
Verify the Java installation:
java -version
javac -version
Both commands should display version information confirming Java 17 installation. The JDK forms the foundation of your Kotlin development environment.
Installation Methods Overview
You can install Kotlin on Rocky Linux 10 using three primary approaches:
- SDKMAN: Software Development Kit Manager offering version management and easy updates
- Snap: Universal Linux package system with automatic updates
- Manual Installation: Direct download from GitHub for complete control
SDKMAN is the recommended method for most developers. It excels at managing multiple SDK versions simultaneously and simplifies updates. Snap works well for users wanting automatic updates without version management complexity. Manual installation suits scenarios requiring specific configurations or offline environments.
Method 1: Installing Kotlin Using SDKMAN (Recommended)
What is SDKMAN?
SDKMAN revolutionizes SDK management on UNIX-based systems. This lightweight tool handles installation, version switching, and updates for numerous SDKs including Kotlin, Gradle, Maven, and more. The parallel version management feature lets you maintain different Kotlin versions for various projects.
Thousands of developers trust SDKMAN for its reliability and ease of use. The tool operates entirely in user space, requiring no root privileges after initial dependencies are installed.
Installing SDKMAN
Download and install SDKMAN with a single command:
curl -s "https://get.sdkman.io" | bash
This script downloads SDKMAN and sets up the necessary configuration files in your home directory. You’ll see progress messages as the installation proceeds.
Once complete, initialize SDKMAN in your current terminal session:
source "$HOME/.sdkman/bin/sdkman-init.sh"
Verify the installation succeeded:
sdk version
The command displays your SDKMAN version number, confirming successful setup.
If you encounter issues, ensure curl is installed and your internet connection is stable. Some corporate networks block the installation script; contact your network administrator if downloads fail.
Installing Kotlin via SDKMAN
With SDKMAN ready, installing Kotlin becomes remarkably simple:
sdk install kotlin
SDKMAN automatically downloads the latest stable Kotlin release and configures it as your default version. The download progress bar shows real-time status. Installation typically completes within minutes, depending on your connection speed.
Kotlin installs to ~/.sdkman/candidates/kotlin/ by default. SDKMAN handles all PATH configurations automatically, so Kotlin commands become immediately available.
Confirm the installation:
kotlin -version
You should see output similar to: Kotlin version 1.9.22-release-704.
Managing Kotlin Versions with SDKMAN
SDKMAN’s version management capabilities truly shine when working across multiple projects. View all available Kotlin versions:
sdk list kotlin
This displays a comprehensive list of Kotlin releases, marking your current version.
Install a specific version:
sdk install kotlin 1.9.20
Switch between installed versions temporarily:
sdk use kotlin 1.9.20
This changes the Kotlin version for your current terminal session only.
Set a permanent default version:
sdk default kotlin 1.9.20
Remove versions you no longer need:
sdk uninstall kotlin 1.8.0
This flexibility makes SDKMAN invaluable for maintaining multiple projects with different Kotlin requirements.
Method 2: Installing Kotlin Using Snap
Installing Snapd on Rocky Linux 10
Snap packages provide universal Linux application distribution. First, enable the EPEL repository, which contains snapd:
sudo dnf install epel-release -y
Install snapd:
sudo dnf install snapd -y
Enable and start the snapd service:
sudo systemctl enable --now snapd.socket
Create the classic snap symbolic link:
sudo ln -s /var/lib/snapd/snap /snap
Log out and log back in to ensure PATH updates take effect. Alternatively, restart your system.
Installing Kotlin via Snap
Install Kotlin using snap:
sudo snap install --classic kotlin
The --classic flag grants Kotlin full system access necessary for development tools. Snap downloads, installs, and configures Kotlin automatically.
Verify installation:
kotlin -version
Snap handles updates automatically in the background, keeping your Kotlin installation current without manual intervention.
Snap vs SDKMAN Comparison
SDKMAN offers superior version management, letting you switch between Kotlin releases effortlessly. It installs in user space, avoiding system-wide changes. Snap provides automatic updates and simpler initial setup but lacks granular version control. Choose SDKMAN for professional development environments requiring version flexibility. Opt for Snap when you need hassle-free automatic updates on a single-version setup.
Method 3: Manual Installation from GitHub
Downloading Kotlin Compiler
Visit the official Kotlin GitHub releases page to download the compiler manually. Using wget from the terminal:
wget https://github.com/JetBrains/kotlin/releases/download/v1.9.22/kotlin-compiler-1.9.22.zip
Replace the version number with your desired release. Verify download integrity using SHA256 checksums provided on the release page.
Installing Manually
Extract the downloaded archive:
unzip kotlin-compiler-*.zip
Move the extracted directory to /opt:
sudo mv kotlinc /opt/
Add Kotlin to your system PATH by editing your shell configuration file:
nano ~/.bashrc
Add this line at the end:
export PATH=$PATH:/opt/kotlinc/bin
Save and exit. Apply the changes:
source ~/.bashrc
Verify installation:
kotlin -version
Manual installation requires you to handle updates yourself by repeating this process with newer releases.
Post-Installation Configuration
Configuring Environment Variables
Set the KOTLIN_HOME variable for better tool integration:
echo 'export KOTLIN_HOME=/opt/kotlinc' >> ~/.bashrc
echo 'export PATH=$PATH:$KOTLIN_HOME/bin' >> ~/.bashrc
source ~/.bashrc
For system-wide configuration, edit /etc/profile instead, though this requires root access.
Verifying Complete Installation
Run comprehensive verification checks:
kotlin -version
kotlinc -help
Test the Kotlin REPL (Read-Eval-Print Loop):
kotlinc
This launches an interactive Kotlin shell. Type println("Hello") and press Enter. You should see “Hello” printed. Exit with :quit.
Creating Your First Kotlin Program
Writing a Simple Kotlin Program
Create a new file named HelloWorld.kt:
nano HelloWorld.kt
Enter this code:
fun main() {
println("Hello, Rocky Linux!")
println("Welcome to Kotlin development")
}
Save and exit the editor. Kotlin uses the .kt file extension for source files.
Compiling Kotlin Code
Compile your program using kotlinc:
kotlinc HelloWorld.kt -include-runtime -d HelloWorld.jar
The -include-runtime flag bundles the Kotlin runtime library into your JAR file, making it standalone. The -d flag specifies the output filename.
Compilation generates HelloWorld.jar in your current directory. The process converts your Kotlin code into Java bytecode that runs on any JVM.
Running Compiled Kotlin Program
Execute your compiled program:
java -jar HelloWorld.jar
You’ll see:
Hello, Rocky Linux!
Welcome to Kotlin development
Congratulations! You’ve successfully written, compiled, and executed your first Kotlin program on Rocky Linux 10.
Additional Tools and IDE Integration
Installing IntelliJ IDEA
IntelliJ IDEA, created by JetBrains (Kotlin’s developers), offers the best Kotlin development experience. Download JetBrains Toolbox for Rocky Linux:
wget https://download.jetbrains.com/toolbox/jetbrains-toolbox-latest.tar.gz
tar -xzf jetbrains-toolbox-latest.tar.gz
./jetbrains-toolbox
Install IntelliJ IDEA Community Edition through Toolbox. The IDE includes built-in Kotlin support with intelligent code completion, refactoring tools, and debugging capabilities.
Setting Up VS Code for Kotlin
Visual Studio Code provides a lightweight alternative. Install VS Code on Rocky Linux:
sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
sudo sh -c 'echo -e "[code]\nname=Visual Studio Code\nbaseurl=https://packages.microsoft.com/yumrepos/vscode\nenabled=1\ngpgcheck=1\ngpgkey=https://packages.microsoft.com/keys/microsoft.asc" > /etc/yum.repos.d/vscode.repo'
sudo dnf install code -y
Install the Kotlin extension from the VS Code marketplace for syntax highlighting and basic language support.
Troubleshooting Common Issues
Java-Related Errors
If you encounter “JAVA_HOME not set” errors, configure the variable:
echo 'export JAVA_HOME=/usr/lib/jvm/java-17-openjdk' >> ~/.bashrc
source ~/.bashrc
Verify with:
echo $JAVA_HOME
For “javac command not found” errors, ensure you installed the java-17-openjdk-devel package, not just the runtime.
SDKMAN Installation Issues
“curl: command not found” indicates missing dependencies. Install curl:
sudo dnf install curl -y
Permission denied errors typically mean directory access restrictions. SDKMAN installs in your home directory, which should resolve most permission issues.
Network connectivity problems may require proxy configuration. Set HTTP proxy before installation:
export http_proxy=http://proxy.example.com:8080
export https_proxy=http://proxy.example.com:8080
Kotlin Compiler Errors
“kotlin: command not found” after installation means PATH configuration failed. Verify your PATH includes Kotlin:
echo $PATH
Reload your shell configuration:
source ~/.bashrc
For persistent issues, check that SDKMAN initialization runs on shell startup. Your ~/.bashrc should contain SDKMAN initialization code.
Best Practices and Maintenance
Keeping Kotlin Updated
SDKMAN users can upgrade Kotlin easily:
sdk upgrade kotlin
This command checks for and installs the latest version. Review release notes before upgrading to understand breaking changes.
Snap users receive automatic updates in the background. Check your current version periodically to confirm updates installed successfully.
Manual installation users must download new releases and repeat the installation process. Subscribe to Kotlin’s GitHub releases for notifications.
Managing Multiple Projects
Different projects often require different Kotlin versions. SDKMAN’s version switching makes this effortless. Create a .sdkmanrc file in your project root:
kotlin=1.9.20
SDKMAN automatically switches to this version when you enter the directory.
For build tool integration, specify Kotlin versions in your build.gradle.kts or pom.xml files. Gradle and Maven handle Kotlin plugin versions independently of your system installation.
Congratulations! You have successfully installed Kotlin. Thanks for using this tutorial for installing Kotlin programming language on your Rocky Linux 10 system. For additional help or useful information, we recommend you check the official Kotlin website.