Task | Command | Description |
---|---|---|
Check Kotlin Version | kotlinc -version |
Verifies Kotlin installation. |
Compile Kotlin File | kotlinc filename.kt |
Compiles the file into bytecode (filename.class ). |
Run Compiled Class | kotlin filenameKt |
Runs the compiled Kotlin file. |
Compile with Runtime | kotlinc filename.kt -include-runtime -d filename.jar |
Creates a .jar file including the runtime. |
Run JAR File | java -jar filename.jar |
Runs the compiled JAR file. |
Run Kotlin Script | kotlin filename.kt |
Executes a Kotlin script without compiling. |
Compile Multiple Files | kotlinc file1.kt file2.kt -d output.jar |
Compiles multiple Kotlin files into one JAR. |
Enable Debugging | kotlinc -J"-Xdebug" filename.kt |
Compiles with debugging enabled. |
Run REPL (Interactive Mode) | kotlinc |
Opens an interactive Kotlin shell. |
Exit REPL | :quit |
Exits the interactive mode. |
- Write a simple Kotlin program (
hello.kt
):fun main() { println("Hello, Kotlin!") }
- Compile the file:
kotlinc hello.kt -include-runtime -d hello.jar
- Run the compiled JAR:
java -jar hello.jar
Now you can easily compile and run Kotlin programs! 🚀 Let me know if you need help. 😊