Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xpepper/e85df331b3d604cf2a52730de4d7fa01 to your computer and use it in GitHub Desktop.
Save xpepper/e85df331b3d604cf2a52730de4d7fa01 to your computer and use it in GitHub Desktop.
from kotlin source to java execution of the generated bytecode

Write the simplest Kotlin file, and name it Main.kt:

fun main(args: Array<String>) {
    println("Hello world!")
}

Then compile the Kotlin file with kotlinc, which runs the Kotlin compiler

❯ kotlinc Main.kt

Then run the generated MainKt.class bytecode with

❯ java -cp ~/.sdkman/candidates/kotlin/current/lib/kotlin-stdlib.jar:.  MainKt

(where ~/.sdkman/candidates/kotlin/current/lib/ is my actual path to the Kotlin lib folder).

And you'll get:

Hello world!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment