How to install the Kotlin programming language 12 on Debian

王林
Release: 2024-02-20 09:42:02
forward
962 people have browsed it

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.

如何在 Debian 上安装 Kotlin 编程语言 12

Installing the Kotlin programming language 12 Bookworm on Debian

step 1. Start by updating existing system packages. Open a terminal and enter the following command:

sudo apt update
sudo apt upgrade
Copy after login

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
Copy after login

Verify installation by checking Java version:

java -version
Copy after login

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
Copy after login

Unzip the downloaded zip file:

unzip kotlin-compiler-1.9.22.zip
Copy after login

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

sudo mv kotlinc/bin/* /usr/local/bin/
Copy after login

Clean downloaded and extracted files:

rm -rf kotlinc
rm kotlin-compiler-1.9.22.zip
Copy after login

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

kotlin -version
Copy after login

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!")
}
Copy after login

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

kotlinc HelloWorld.kt -include-runtime -d HelloWorld.jar
java -jar HelloWorld.jar
Copy after login

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!

Related labels:
source:mryunwei.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template