LoginSignup
25
30

More than 5 years have passed since last update.

VSCodeでKotlinの実行環境を作る

Last updated at Posted at 2018-11-22

環境

  • OS: macOS Mojave
  • エディタ: Visual Studio Code(以下VSCode)

作業手順

kotlinをインストールします

$ brew update
$ brew install kotlin

VSCodeの以下のプラグインをインストールします。

VSCodeのユーザ設定を変更します

vscode-code-runner はデフォルトでkotlincを使ってコンパイルしますが、これだとエラーが発生するのでkotlinc-jvmを使うように変更します。

VSCodeのユーザ設定で、以下を追記してください。

    "code-runner.executorMap": {
        "kotlin": "cd $dir && kotlinc-jvm $fileName -include-runtime -d $fileNameWithoutExt.jar && java -jar $fileNameWithoutExt.jar"
    }

Kotlinプログラムの実行

VSCodeでKotlinプログラムファイル(拡張子.kt)を作成し、右クリック > Run Code とすると、コードが実行されます。

スクリーンショット 2018-11-22 20.16.16.png

参考

25
30
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
25
30