Home Belajar Android Learning Kotlin (Basic) Using Visual Studio Code

Learning Kotlin (Basic) Using Visual Studio Code

visual studio code kotlin

I know kotlin for 2-3 years ago, but I was never interested, but now, after google make kotlin offcial language for android, and they give so many sample of codes. I think its the time for me to learn it.

In general, many people already know, the easiest ways to write or make android application using kotlin is in android studio.

I think, its to slow to execute some kotlin scripts jus for learn algorithm or just get used to writing kotlin syntax.

I usually use the visual studio code, to learn new programming language.

This is how I setts, visual studio code for kotlin language.

FYI: I am using windows 10

Install Kontlin Extensions and reload in Visual Studio Code

install kotlin extendsions in visual studio code by mathiasfrolich

Install code runner

install code runner visual studio code
Using Code Runner, we can execute many language just using block script and execute

For now we can write kotlin script, for the first time “Hello Word” of course

  • Create new file : heloworld.kt
  • Write the script
  • Select all or choose the script that we want to execute

For the result, look at the output (bottom), if we get “kotlinc is not recognized as internal or external command…..”, it means we’ve not installed kotlin compiler.

kotlinc is not recognized as internal or external command

Install Kotlin Compiler

The easiest way to install kotlin compiler is using chocolatey, if don have it, you can install it first https://chocolatey.org/install#organization

install_chocolatey_in_windows_10

After chocholatey instaled, we can install kotlin compiler https://kotlinlang.org/docs/tutorials/command-line.html

install kotlin complier visual studio windows 10

And please look the kotlin instaled path “C:\ProgramData\chocolatey\lib\kotlinc\tools\kotlinc\bin

Add “C:\ProgramData\chocolatey\lib\kotlinc\tools\kotlinc\bin” to Environment Variabel

Control Panel, Advanced System Settings, Environment Variabel

Click Edit

Add Path C:\ProgramData\chocolatey\lib\kotlinc\tools\kotlinc\bin

Now we can try kotlin script, if you can execute without error, you have made visual studio as kotlin editor.

Leave a Reply