LoginSignup
0
1

More than 5 years have passed since last update.

Kotlin スクリプト実行 (kscript)

Last updated at Posted at 2017-01-13

こんにちは。
Kotlin スクリプトファイルを(shebang を付けて)実行させることができる kscript というものを見つけました。これの実体 (https://git.io/vaoNi) はシェルスクリプトです1。(似たものとして kotlin-scripting-kickstarter というものもあるようです。)

インストールして動かしてみました。

$ curl -L -o ~/bin/kscript https://git.io/vaoNi && chmod u+x ~/bin/kscript
$ cat hello.kts 
#!/usr/bin/env kscript
println("Hello, World!")
$ ./hello.kts 
Hello, World!
$ unzip -l .hello.76a762.jar 
Archive:  .hello.76a762.jar
  Length     Date   Time    Name
 --------    ----   ----    ----
       55  01-13-17 17:00   META-INF/MANIFEST.MF
      523  01-13-17 17:00   Hello.class
      748  01-13-17 17:00   Main_Hello.class
 --------                   -------
     1326                   3 files

なお Kotlin は homebrew 利用でインストールしました。

$ brew install kotlin
$ kotlinc-jvm
Welcome to Kotlin version 1.0.6-release-127 (JRE 1.8.0_102-b14)
Type :help for help, :quit for quit
>>> println("Hello, World!")
Hello, World!

0
1
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
0
1