LoginSignup
1
0

More than 3 years have passed since last update.

CLIで簡単にKotlinを動かす

Last updated at Posted at 2019-06-18

Kotlinインストール

Homebrewでインストール

$ brew install kotlin

jarにコンパイルして実行

コーディング

hello.kt を作成

hello.kt
fun main(args: Array<String>) {
    println("Hello, World!")
}

コンパイル

kotlinc で jarファイルにコンパイル

$ kotlinc hello.kt -include-runtime -d hello.jar

Hello, World!実行!

$ kotlin hello.jar
Hello, World!

ヤッタネ!

scriptファイルとして実行

コーディング

hello.kts を作成

hello.kts
println("Hello, World!")

scriptオプションを付けて実行!

$ kotlinc -script hello.kts
Hello, World!

ヤッタネ!

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0