Your first Kotlin program
$count++; if($count == 1) { include "../mobilemenu.php"; } if ($count == 2) { include "../sharemediasubfolder.php"; } ?>
In this example, you’ll write, compile, and run a simple Kotlin application that prints “Hello, Kotlin!” to the console.
Prerequisites
- Java JDK 8 or newer installed
- Kotlin compiler on your PATH or an IDE with Kotlin support
Step 1: Create the Source File
Create a file named Hello.kt with the following content:
fun main() {
println("Hello, Kotlin!")
}
Step 2: Compile
Open your terminal, navigate to the directory containing Hello.kt, and run:
kotlinc Hello.kt -include-runtime -d Hello.jar
This produces Hello.jar containing your compiled program and the Kotlin runtime.
Step 3: Run
Execute your program with:
java -jar Hello.jar
You should see:
Hello, Kotlin!
Next Steps
- Try modifying the println message
- Explore variables, functions, and control flow
- Use an IDE like IntelliJ IDEA to step through your code