DebianDebian Based

How To Install Kotlin Programming Language on Debian 12

Install Kotlin Programming Language on Debian 12

In this tutorial, we will show you how to install Kotlin Programming Language on Debian 12. Kotlin, a statically typed programming language, has been making waves in the world of software development. With its concise syntax, interoperability with Java, and robust tooling support, Kotlin offers a plethora of benefits that make it a preferred choice for many developers.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of the Kotlin Programming Language on a Debian 12 (Bookworm).

Prerequisites

  • A server running one of the following operating systems: Debian 12 (Bookworm).
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • SSH access to the server (or just open Terminal if you’re on a desktop).
  • You will need an active internet connection to download the Kotlin package.
  • A non-root sudo user or access to the root user. We recommend acting as a non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.

Install Kotlin Programming Language on Debian 12 Bookworm

Step 1. Start by updating the existing system packages. Open the terminal and input the following commands:

sudo apt update
sudo apt upgrade

These commands will fetch the list of available updates and upgrade the current packages, ensuring your system is up-to-date.

Step 2. Installing Java.

Kotlin runs on the Java Virtual Machine (JVM), making the Java Development Kit (JDK) a prerequisite for Kotlin. The JDK provides the environment for developing and running Kotlin applications.

To install JDK on Debian 12, execute the following commands:

sudo apt install default-jdk

Verify the installation by checking the Java version:

java -version

Step 3. Installing Kotlin Compiler.

With JDK installed, you can now proceed to install the Kotlin compiler. The Kotlin compiler is essential for converting Kotlin code into a format that can be executed by the JVM.

To download and install the Kotlin compiler using CLI, follow these steps:

wget https://github.com/JetBrains/kotlin/releases/download/v1.9.22/kotlin-compiler-1.9.22.zip

Extract the downloaded zip file:

unzip kotlin-compiler-1.9.22.zip

Move the extracted files to the /usr/local/bin directory:

sudo mv kotlinc/bin/* /usr/local/bin/

Clean up the downloaded and extracted files:

rm -rf kotlinc
rm kotlin-compiler-1.9.22.zip

After installing the Kotlin compiler, it’s important to verify the installation. This can be done by checking the installed version of Kotlin:

kotlin -version

If the installation is successful, this command will output the installed version of Kotlin.

Step 4. Writing Your First Kotlin Program

With Kotlin installed, you can now write your first Kotlin program. Open a text editor, write the following code, and save the file as HelloWorld.kt:

fun main() {
    println("Hello, World!")
}

To compile and run the Kotlin program, use the following commands:

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

The first command compiles the Kotlin file into a JAR file, and the second command runs the JAR file. If everything is set up correctly, you should see “Hello, World!” printed in the terminal.

Congratulations! You have successfully installed Kotlin. Thanks for using this tutorial to install the latest version of Kotlin Programming Language on Debian 12 Bookworm. For additional help or useful information, we recommend you check the official Kotlin website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is a seasoned Linux system administrator with a wealth of experience in the field. Known for his contributions to idroot.us, r00t has authored numerous tutorials and guides, helping users navigate the complexities of Linux systems. His expertise spans across various Linux distributions, including Ubuntu, CentOS, and Debian. r00t's work is characterized by his ability to simplify complex concepts, making Linux more accessible to users of all skill levels. His dedication to the Linux community and his commitment to sharing knowledge makes him a respected figure in the field.
Back to top button