LoginSignup
3
5

More than 5 years have passed since last update.

Sublime Text 3 + KotlinでHello!

Last updated at Posted at 2016-11-24

JavaをSublimeTextでコンパイルできるというのを知って、Kotlinでもできるのではと思った...

Java版はこちら
Sublime Text3で、Javaをビルド→実行する方法

Kotlinをインストール

Homebrewを使います
(こちらを参考にMacにHomebrewをインストールする

$ brew install kotlin

Kotlin用BuildSystem作成

SublimeTextのメニューからTools -> Build System -> new Build System...にアクセスします

Kotlin.sublime-build
{
    "shell_cmd": "kotlinc -script $file_name",
    "selector": "source.kts",
}

これを Kotlin.sublime-buildというタイトルで保存します
保存先はPackages/User/です

Tools -> Build SystemKotlinができてると思いますので選択します

実行

hello.kts
println("HELLO")

ファイル名は**.ktsじゃないとダメなようです

保存したら、command+bまたはcommand+shift+bで実行です

結果

HELLO
[Finished in 3.1s]

参考

sublime text 3 + kotlin で Hello World
http://kotlinlang.org/docs/tutorials/command-line.html
http://y-anz-m.blogspot.jp/2012/11/sublime-text-2-typescript.html

追記

ちょこっとKotlinをためすだけならこちらも
http://try.kotlinlang.org/#/Examples/Hello,%20world!/Simplest%20version/Simplest%20version.kt

3
5
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
3
5