What can be written to determine the version of Kotlin at runtime?
fun main(args : Array<String>) {
println("v" + System.getProperty("java.version"))
}
prints a version, but it is the Java JDK version. Using "kotlin.version" prints null. Can this be done at runtime?
If the general answer is no, is there a way to embed this information from the compile phase into a particular function or class?
Kotlin includes its own standard class library (the Kotlin runtime), separate to the Java class library. To distribute a jar file that can be run by anyone with a plain old JRE, you need to bundle the Kotlin runtime as well.
In your Android studio, Go to Tools -> Kotlin -> Configure Kotlin Updates. Save this answer.
1.7.20 / 29 September 2022. Typing discipline. Inferred, static, strong. Platform. Android.
The Kotlin compiler for JVM compiles Kotlin source files into Java class files. The command-line tools for Kotlin to JVM compilation are kotlinc and kotlinc-jvm . You can also use them for executing Kotlin script files. In addition to the common options, Kotlin/JVM compiler has the options listed below.
Use kotlin.KotlinVersion.CURRENT
:
fun main(args: Array<String>) {
println(KotlinVersion.CURRENT)
}
Try it out here by changing the version in the bottom-right corner of the page.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With