Configure VSCode for Kotlin development (2023)

This tutorial will show you how to set up yours.visual studio codeKotlin project editor. By now you should have your version of vscode installed. If not, you can refer to ourmailhow to install it on Windows, Linux or Mac.

Visual Studio Code is the perfect choice for building Kotlin projects. It offers IDE features like autocompletion, text/syntax highlighting, text formatting, and lint. Your code not only looks great, but vscode gives you the power to refactor and control your project. This is possible with the rich ecosystem of extensions and plugins for Kotlin.

The first part of this tutorial focuses on configuring extensions and plugins. With that done, we'll show you how to create a Kotlin project in vscode or import an existing one. In the end, we'll focus on development, including building and debugging a Kotlin application and running tests.

As a new part of this tutorial, we will discuss how to addGradleNameSupport your Kotlin project in Visual Studio Code.

Satisfied Disguise

1 operating system

1.1 Using Kotlin with vscode on Windows

1.2 Command Line Compiler - kotlinc

2 extensions and plugins

(Video) Kotlin - Visual Studio Code

Create 3 projects

3.1 Hello world

3.2 Import existing projects

4 development

4.1 Structure

5 run

5.1 Debugging

(Video) Setup Kotlin Environment in Visual studio code | Download Kotlin compiler | Setup kotlin Env

6 Gradle project for Kotlin in VSCode

6.1 Create a new Gradle project

6.2 Create task.json for Gradle

6.3 Add Kotlin code to the Gradle project

6.3.1 Project structure

6.4 Clase principal Kotlin Gradle

work system

Kotlin project development does not depend much on your operating system. All you need to do is have Visual Studio Code installed (see ourmail🇧🇷 Depending on your build goal, you may also need a Java Virtual Machine or Java Runtime Environment.

Furthermore, development is platform-independent and can be done on all major operating systems, including Linux (for example, Ubuntu), Windows, and Mac.

Using Kotlin with vscode on Windows

Our tutorial mainly focuses on the Windows operating system. We manually installed the Java Runtime Environment and the Kotlin compiler. We are also using the standard version of Visual Studio Code.

Command Line Compiler - kotlinc

It is imperative that you have a valid compiler available to build Kotlin projects. This step largely depends on how you installed Kotlin and/or Java on your computer. If in doubt, we advise you to check the official website.sidepor Jetbrains.

(Video) How to Run Kotlin in VSCode - Hello Kotlin!

Extensions and Plugins

You can work on Kotlin projects without Visual Studio Code extensions and plugins. However, we recommend that you install them as they offer a better coding experience.

Configure VSCode for Kotlin development (1)

On the right hand side of VSCode you will find the market tab. There you can browse all kinds of plugins that improve the default behavior of the editor.

In our case we install the extension "kotlin language“.

In addition, we install the extensionvscode-runner🇧🇷 This plugin provides the functionality to run simple programs directly from the editor.

create projects

We are now ready to create our first Kotlin project in Visual Studio Code.

Hello World

First, let's create a main.kt file with a simple Hello World main function.

fun main() { println("Hello Welt")}

In the image below you can see that the file system is quite simple. Thanks to the first extension we installed, the editor, icons and texts are formatted and highlighted. In the upper right corner you will find a small arrow icon. This icon is from the second plugin. Clicking on the icon will compile the main.kt file and run the application.

Configure VSCode for Kotlin development (2)

If everything went well, ie the compiler was found and no compile errors occurred, the editor prints "Hello World" to the terminal.

Import existing projects

As shown in the Hello World project, you can create or import any project.


Build up

Of course, to create a Kotlin project, you need the Kotlin compiler. You can download it manually from the Jetbrains page we pinned above.

Now you have several options. First, you can use Code Runner, which we installed as an extension to Visual Studio Code. This code runner automatically calls the build command and then runs the application.

The second option, more in keeping with the editor's workflow, is to create a task.json file. To create a task.json file, do the following:

  • Press F1
  • WriteConfigure build task
  • to chooseSet default build task
  • to chooseCreate Task.json file from template
  • to chooseOthers

Your file system should now look like the image below.

Configure VSCode for Kotlin development (3)

You can now change the specific task to create a standard build.

{ // See // for documentation on the tasks.json format. "version": "2.0.0", "tasks": [ { "tag": "echo", "type": "shell", "command": "kotlinc main.kt -include-runtime -d main.jar ", "group": { "type": "build", "is default": real } } ]}

Now if you do Ctrl+Shift+B the build will run.

(Video) Install Java JDK and Kotlin Compiler on Windows 10 | Setup VS Code for Kotlin Programming Language

pick up

To run your application, you also have different options. As in the previous section, you can use the code runner that we installed as a plugin.

The second option is to configure Visual Studio Code to run your application from the command line. Because the build creates an executable JAR file, you can invoke it through the Java Runtime Environment.


You can add a Java debugger to your application. This is possible because it was compiled for Java Runtime Environment

Gradle project for Kotlin in VSCode

In this section, we'll discuss how to set up a Gradle project targeting Kotlin and/or Java in Visual Studio Code. We will guide you step by step through the configuration of all the files and what you need to install.

First, you need to install the following extensions.


  • Java Extension Pack
  • Gradle pairs with Java

Both extensions are required to build and run a Gradle project. Also, you must have the Java Runtime and the standalone Kotlin compiler installed.

Create a new Gradle project

Thanks to the extensions, you can create a new Gradle project by typing:

  • Ctrl + Shift + P
  • digit gradle
  • Select "Create Gradle Java project".
  • Select the folder and project name
  • Select Kotlin as DSL language

The extensions will create a new project as shown in the image below. Note that the .vscode folder may be missing at this point. If it's missing, don't worry. As you can see, the created project contains only Java code. Before changing/adding the Kotlin code, let's set up a tasks.json file to compile and run the project automatically. This helps us see if everything is set up correctly.

Configure VSCode for Kotlin development (4)

Create Task.json for Gradle

configuration environment

  • Ctrl + Shift + P
  • Enter Tasks, select Any (for example, Set Default Build Task)
  • Create Tasks.json from template (enter others)

In the newly created task.json file, we recommend placing at least the following tasks. The first is the default build task that builds your application. The second is the run task, which will eventually open and run your application.

{ "tag": "build", "type": "shell", "command": "./gradlew compile -x test", "problemMatcher": [], "group": { "type": "build" , "isDefault": true } }, { "label": "run", "type": "shell", "command": "./gradlew run", "problemMatcher": [] },
Configure VSCode for Kotlin development (5)

The build task can be activated by running the keyboard shortcut "Ctrl + Shift + B". Both tasks can also be accomplished by typing the following.

  • Ctrl + Shift + P
  • Tasks: perform task
  • Choose Run or Build

After building and running the app, you should have output similar to the following:

> Task :app:runHello World!SUCCESS BUILD in 1s2 runnable tasks: 1 executed, 1 updated * Terminal is reused by tasks, press any key to close it.

Add Kotlin code to the Gradle project

In the next step, we want to add the Kotlin code to our Gradle project in Vscode. In order for it to work properly, we have to adjust As stated in the official Kotlin documentation (, we need to add the plugin to Gradle.

plugins { // Apply the application plugin to add support for building a Java CLI application. Kotlin application ("jvm") version "1.7.10"}

Our goal is the Java Virtual Machine. The displayed version may change in the future. So make sure to check your current kotlin and jvm version.

Project structure

By default, you should follow the following project structure. This is important, otherwise Gradle will have trouble compiling and combining your classes and source files correctly.

project - src - main (root) - kotlin - java

As an example, let's add a new main class in the Kotlin section.

Configure VSCode for Kotlin development (6)

After building the app, you should check your build folder to see if the Kotlin files were parsed correctly and the binaries were compiled correctly.

(Video) Kotlin - Development Environment Setup Tutorial || Kotlin In VS CODE || Kotlin #1

Configure VSCode for Kotlin development (7)

Two sections are created in the build folder; one for Java and one for Kotlin classes.

Kotlin class manager

With the newly compiled Kotlin classes, we can target them as the main entry point of the application. For that we have to change it hour.

application { // Define the main class for the application. mainClass.set("gradleexample.KotlinAppKt")}

After this change, you can build and run the application. The output should look like this:

> Task :app:runHello World in Kotlin!CREATE SUCCESSFULLY in 4s3 runnable tasks: 1 executed, 2 updated * Terminal is reused by tasks, press any key to close it.


Can I develop Android app using VS Code? ›

Visual Studio is one of the popular IDE that is used for developing cross-platform mobile applications. Both Android and iOS mobile applications can be developed using this IDE.

How do you set a VS Code environment? ›

From within VS Code, you can create non-global environments, using virtual environments or Anaconda, by opening the Command Palette (Ctrl+Shift+P), start typing the Python: Create Environment command to search, and then select the command. The command presents a list of environment types: Venv or Conda.

Does Visual Studio support Kotlin? ›

JetBrains provides the official Kotlin plugin for two Integrated Development Environments (IDEs): IntelliJ IDEA and Android Studio. Other IDEs and source editors, such as Eclipse, Visual Studio Code, and Atom, have Kotlin community-supported plugins.

Are Kotlin programmers in demand? ›

Yes, with the popularity of Android and the beginner-friendly nature of Kotlin, it is most certainly worth learning in 2022. If you are an experienced programmer who is proficient in Java, it will only take you a few weeks to learn Kotlin. In fact, Kotlin is starting to surpass many popular languages, including Java.

Is VS code good for debugging? ›

One of the key features of Visual Studio Code is its great debugging support. VS Code's built-in debugger helps accelerate your edit, compile, and debug loop.

What does += mean in Kotlin? ›

The strange += operator in Kotlin

introduce an immutable structure of the class for the plus operator which means any class outside the class can't edit its internal data. introduce a mutable structure of the class for the plusAssign operator which means its internal data can be edited anywhere.

Is Kotlin better than C#? ›

According to the StackShare community, C# has a broader approval, being mentioned in 697 company stacks & 1163 developers stacks; compared to Kotlin, which is listed in 268 company stacks and 208 developer stacks.

Where do I set environment variables in VS Code? ›

  1. Open the start search.
  2. Type in “env” and choose “Edit the system environment variables”
  3. Choose “Environment Variables…”
  4. Set the environment variables: MSYSTEM=MINGW64. CHERE_INVOKING=1. Add C:\msys64\usr\bin to PATH.

How do I enable virtual environment in VS Code? ›

To use a virtual environment for your project/workspace, you need to first make a new one by opening a terminal ( View > Terminal ) and typing python -m venv . venv . Then, you can set the default interpreter for that project by opening the Command Palette ( CTRL+SHIFT+P ) and selecting > Python: Select Interpreter .

How do I set environment variables in Visual Studio? ›

Open your project. Go to Project -> Properties... Under Configuration Properties -> Debugging, edit the 'Environment' value to set environment variables. For example, if you want to add the directory "c:\foo\bin" to the path when debugging your application, set the 'Environment' value to "PATH=%PATH%;c:\foo\bin".

How to setup VS Code for Android development? ›

Installation (VS Code)
  1. Download and install the JDK.
  2. Download Android SDK Tools and install platform-tools, build tools and at least one version of android api.
  3. Download and install this extension.
  4. Ready to go.
Nov 15, 2021

Is VS Code good for Android development? ›

Visual Studio Code is lighter than Android Studio, so if you are genuinely limited by your hardware, you may be better off on Visual Studio Code. Also, some plugins and enhancements are only available for one or the other, so that will impact your decision as well.

How to set up VS Code for Android development? ›

Building & Debugging your app. Connect an Android phone to your computer and open your folder containing the Android project in VS Code, making sure that is the folder directly containing your "app" folder. Then go to the Run tab, tap on "create a launch.

Is Netflix built with Kotlin? ›

The companies like Netflix, Baidu, Autodesk, and as well as smaller businesses recognize the benefits coming from building apps in Kotlin Multiplatform and invest in this technology to resolve their specific problems.

Does Netflix use Kotlin? ›

Netflix is the world's leading video streaming platform with more than 214 million subscribers all over the globe. The company has revamped the current UI player in the Netflix Android application using 100% Kotlin.

Is Kotlin as powerful as Java? ›

Finally, Kotlin has better support for Android development than Java does. This includes features like null safety and Android Extensions that make developing Android applications with Kotlin much easier than with Java. Android developers enjoy the Kotlin compiler, making each Kotlin project way more efficient.

What is the salary of Kotlin developer? ›

Kotlin Developer Salaries
Job TitleSalary
Kamtech Associates Kotlin Developer salaries - 1 salaries reported₹36,341/mo
BlueMasons Kotlin Developer salaries - 1 salaries reported₹16,660/mo
GRUBBRR Programador Android - Kotlin salaries - 1 salaries reported₹7,80,000/yr
3 more rows

How much does a Kotlin programmer earn? ›

The average android kotlin developer salary in the USA is $130,000 per year or $62.50 per hour.

Will Kotlin replace Java in future? ›

Is Kotlin replacing Java? Kotlin language is a popular choice for android development. Kotlin has a range of features that make it more accessible and ideal for android development. However, Kotlin cannot replace Java, which is an old programming language used for several projects other than android development.

Why is VS Code so difficult? ›

Because VS Code was not designed to be easy for beginners to write “Hello World”. It was designed to support professionals whose programs run from 100K SLOC to 250K SLOC, or teams whose programs start at 1M SLOC and go upwards. As such, you need a lot of power and flexibility.

Why is VS Code so laggy? ›

You might have extensions installed that slow Visual Studio down. For help on managing extensions to improve performance, see Change extension settings to improve performance. Similarly, you might have tool windows that slow Visual Studio down.

Is there a better IDE than VS Code? ›

Atom, Visual Studio, Eclipse, IntelliJ IDEA, and WebStorm are the most popular alternatives and competitors to Visual Studio Code.

Is Kotlin the future? ›

The future is bright for Kotlin

One of these reasons is because Kotlin is a particularly modern programming language, meaning that it brings together all the best features of the previous languages.

Is Kotlin an OOP? ›

Kotlin applications are focused on objects rather than data structures because Kotlin is an object-oriented language.

Why is Kotlin so popular? ›

Kotlin is very flexible and you can integrate all of its tools and frameworks into your Kotlin projects. This interoperability feature will allow you to swiftly migrate your project from one platform to another without much hassle. It's easy and simple with Kotlin.

Is Kotlin killing Java? ›

When it comes to Android app development, Java will probably be the first programming language to spring to your mind, however, Kotlin is expected by many to kill java. Java has issues that can make a developer's job more difficult.

Why isn't Kotlin more popular? ›

Kotlin is too complicated.”

Beginners tend to start writing Kotlin just like they'd write Java. As they get more comfortable with the language, they'll likely push some features (e.g. extensions and inline functions) too far, making the codebase impenetrable to newcomers.

Does Kotlin overtake Java? ›

Kotlin may not have overtaken Java quite yet, but it's become one of the most in-demand programming languages in the world. It's positioned itself as a true Java competitor, and it's still very possible that it will fully overtake Java at some point in the future.

What languages can you write in VS Code? ›

Learn about programming languages supported by VS Code. These include: C++ - C# - CSS - Dart - Dockerfile - F# - Go - HTML - Java - JavaScript - JSON - Julia - Less - Markdown - PHP - PowerShell - Python - R - Rust - SCSS - T-SQL - TypeScript.

Where can I write Kotlin code? › is an interactive code editor on the web where you can practice writing Kotlin programs.

What languages can VS Code use? ›

Visual Studio Code ships by default with English as the display language and other languages rely on Language Pack extensions available from the Marketplace. After installing the Language Pack extension and following the prompt to restart, VS Code will use the Language Pack matching your operating system's UI language.

Can I use VS Code instead of Android Studio? ›

Both the IDE are really good. But Android Studio takes more time to open and it also consume more memory than VS Code. If you are beginner then go for Android Studio but after some time you can shift to VS code.

Why use VS Code instead of Visual Studio? ›

VS Code is comparatively faster. Visual Studio has a free editor for developers to use but also comes with a better and paid IDE version. VS Code is completely free of cost and is open-source. VS engages the best and the most advanced IntelliSense.

Is VS Code a full IDE? ›

Visual Studio or VS code? If you weren't knowing it before then let me tell you that VS code or Visual Studio Code is an editor while Visual Studio is an IDE (Integrated Development Environment).

Does Google use VS Code? ›

Various teams at Google are using Visual Studio Code extensively in a number of projects, including Chrome, Angular and more.

Is Kotlin worth learning in 2022? ›

It is a better option for both beginners as well as experienced developers as it improves productivity by making debugging easier. The use of Kotlin is not only limited to Android apps. As it is JVM based so can be run easily on every platform that supports JVM. Kotlin allows you to do front-end development also.

What big companies use Kotlin? ›

Well known companies/products using Kotlin
  • Google.
  • Amazon.
  • Netflix.
  • Pinterest.
  • Uber.
  • Foursquare.
  • Trello.
  • Capital One.


1. Kotlin with VSCode on Windows
2. How to install Kotlin in Vscode 2022
(Tutor Awan)
3. How to SETUP Visual Studio Code for Kotlin
(Tamil Software)
4. How to run kotlin in Visual Studio Code
(Hindi Life)
5. how to migrate code from android studio to vscode 2020 | android app development in vscode
6. Setting up Standalone Kotlin compiler and Visual Studio Code


Top Articles
Latest Posts
Article information

Author: Geoffrey Lueilwitz

Last Updated: 10/26/2023

Views: 6356

Rating: 5 / 5 (60 voted)

Reviews: 91% of readers found this page helpful

Author information

Name: Geoffrey Lueilwitz

Birthday: 1997-03-23

Address: 74183 Thomas Course, Port Micheal, OK 55446-1529

Phone: +13408645881558

Job: Global Representative

Hobby: Sailing, Vehicle restoration, Rowing, Ghost hunting, Scrapbooking, Rugby, Board sports

Introduction: My name is Geoffrey Lueilwitz, I am a zealous, encouraging, sparkling, enchanting, graceful, faithful, nice person who loves writing and wants to share my knowledge and understanding with you.