Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Where does the vs-code-runner extension get the information to build and run Kotlin programs?

I have a simple main.kt file in VS Code:

fun main() {
  println("Hello world");
}

I tried pressing F5 (I have a Node background) and it says "You don’t have an extension for debugging Kotlin." I installed vscode-runner by HarryHopkinson. F5 still give the same message, but Ctrl-Alt-N builds and runs the program. It seems to be executing the following:

cd "d:\Documents\kotlin\hello" && kotlinc main.kt -include-runtime -d main.jar && java -jar main.jar

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

From where does vscode-runner get the parameters to execute this set of instructions?

>Solution :

It just uses the executor map setting. The default value is defined in https://github.com/formulahendry/vscode-code-runner/blob/master/package.json, where it currently has the following:

".kt": "cd $dir && kotlinc $fileName -include-runtime -d $fileNameWithoutExt.jar && java -jar $fileNameWithoutExt.jar",
".kts": "kotlinc -script",

More info about the executor map setting and the template variables that can be used in it can be found at https://github.com/formulahendry/vscode-code-runner/blob/master/README.md#configuration.

F5‘s default binding in VS Code is the following:

{ "key": "f5", "command": "debug.openView",
                  "when": "!debuggersAvailable" },
{ "key": "f5", "command": "workbench.action.debug.start",
                  "when": "debuggersAvailable && debugState == 'inactive'" },
{ "key": "f5", "command": "workbench.action.debug.continue",
                  "when": "debugState == 'stopped'" },
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading