Kotlin has a strong image of Android development, but since it is a general-purpose language that is compatible with Java and can be used on the server side, I tried Kotlin easily on the command line without using an IDE.
$ brew update
$ brew install kotlin
$ vim hello.kt
...(Edit with your favorite editor)
$ cat hello.kt
fun main(args: Array<String>) {
println("Hello, World!")
}
fun
println
--In Java, it's System.out.println
, but since Kotlin's standard library wraps Java's standard library, it can be written concisely.$ kotlinc hello.kt -include-runtime -d hello.jar
$ java -jar hello.jar
-d
option.-include-runtime
option, include Kotlin's runtime library in a jar and output it in an executable format
-* Kotlin runtime is required to execute code compiled by Kotlin compilerjava
commandRecommended Posts