Home >Computer Tutorials >Computer Knowledge >How to install the Kotlin programming language 12 on Debian
Kotlin is a statically typed programming language that has attracted huge attention in the field of software development. Its concise and easy-to-understand syntax, good compatibility with Java, and rich tool support provide many advantages to developers, so many developers choose Kotlin as their language of choice.
step 1. Start by updating existing system packages. Open a terminal and enter the following command:
sudo apt update sudo apt upgrade
These commands will get a list of available updates and upgrade current packages, ensuring your system is up to date.
Step 2. Install Java.
Kotlin runs on the Java Virtual Machine (JVM), which makes the Java Development Kit (JDK) a prerequisite for Kotlin. The JDK provides an environment for developing and running Kotlin applications.
To install JDK on Debian 12, execute the following command:
sudo apt install default-jdk
Verify installation by checking Java version:
java -version
Step 3. Install Kotlin Compiler.
After installing the JDK, 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 the CLI, follow these steps:
wget https://github.com/JetBrains/kotlin/releases/download/v1.9.22/kotlin-compiler-1.9.22.zip
Unzip the downloaded zip file:
unzip kotlin-compiler-1.9.22.zip
Move the unzipped files to the /usr/local/bin
directory:
sudo mv kotlinc/bin/* /usr/local/bin/
Clean downloaded and extracted files:
rm -rf kotlinc rm kotlin-compiler-1.9.22.zip
After installing the Kotlin compiler, it is important to verify the installation. This can be done by checking the installed Kotlin version:
kotlin -version
If the installation is successful, this command will output the installed Kotlin version.
Step 4. Write your first Kotlin program
After installing Kotlin, 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 a 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.
Thank you for using this tutorial to install the latest version of the Kotlin programming language on Debian 12 Bookworm. For more help or useful information, we recommend you check out the official Kotlin website.
The above is the detailed content of How to install the Kotlin programming language 12 on Debian. For more information, please follow other related articles on the PHP Chinese website!