Download The Ultimate Tutorial: Getting Started With Kotlin

80 pages of hands-on tutorial right into your email inbox. Learn how to use state of the art development environment and build a full-fledged command-line application. You will receive free updates to the tutorial. Start learning Kotlin today!

Starting With Kotlin on Windows

This guide is an add-on to the Ultimate Tutorial: Getting Started With Kotlin (get it here). It explains how to install all the dependencies Kotlin requires.

Looking for Mac OS X? Here is the link to the guide.

Looking for Linux? Here is the link to the guide.


This tutorial will require you to run some command-line programs in BASH. If you already have some BASH emulator installed and comfortable using it, feel free to skip this section.

Git BASH is one of the best BASH emulators for Windows.

Git BASH is included in Git for Windows. Go over there and download Git for Windows. Then launch the downloaded installer program.

When Windows asks you for the permission to install this software, answer “Yes”:

​When the setup program launches it will ask you if you accept the GNU GPL v2 license. Press “Next” to accept it and proceed with the installation:

Next step is to choose the location where you want to install Git for Windows. The default option should be good enough. If you have a preference of where to install programming tools, feel free to customize the installation directory:

Press “Next” to proceed. Now, you will need to select components that you want to install. The default selection should be good to go:

Let’s press the “Next” button to proceed. This step is about start menu folder. The default setting should do the trick:

Now, press “Next” to continue. On this screen, you will be able to choose how exactly Git is going to be installed on your Windows. The safest option is to go for “Use Git from Git Bash only”:

Press the “Next” button to continue. The next screen is about choosing whether you want to use OpenSSL or Windows Secure Channel Library. It does not matter for our purposes. The default option should do the trick:

At this point, click on that “Next” button to proceed. The next screen lets you configure how line endings should be handled (CRLF vs. LF). The default recommended option should do:

Hit that “Next” button to continue. That is a lot of steps. I know, right. The next screen lets you choose between two terminal emulation settings. The default option should work just fine:

After clicking on the “Next” button, you will see some extra settings. Default settings should do the trick:

That was the last step. Let’s hit that “Install” button. Finally! You should see the installing progress now:

After the installation is done, you should see the final screen indicating that installation was a success:

​After closing the installation window using that “Finish” button, we need to check if Git BASH works as expected. Let’s launch Git BASH application (from the start menu or “Search Windows”).

When launched you should see a terminal window like this:

Once you have launched the terminal emulator verify that it works by typing the following command and pressing Enter:

$ echo "Hello, World."

$ is not part of the command – it is just a prompt that terminal application usually outputs. No need to type it. Same applies for any terminal command I ask you to run in this tutorial. If that worked, you should see Hello, World. output like that:

$ echo "Hello, World."
Hello, World.


This tutorial assumes you have OpenJDK installed. Skip this section if you already have OpenJDK installed. Though, you might want to update the version of your OpenJDK if it is too old. Then continue reading.

To check if OpenJDK is installed and has proper version run the following command and it should produce the following output:

$ java -version
openjdk version "1.8.0_141-1-ojdkbuild"
OpenJDK Runtime Environment (build 1.8.0_141-1-ojdkbuild-b16)
OpenJDK 64-Bit Server VM (build 25.141-b16, mixed mode)

Your openjdk version and other numbers may vary.

If you get something like:

bash: java: command not found

That means that you do not have OpenJDK installed. To install it go to the ojkbuild open-source community page and download a suitable .msi installer for OpenJDK 1.8.* version for your Windows.

For example, if you have 64-bit Windows installed, you should use this link to download it:

When the download is finished, launch the installer. Because this is an open-source community build it is probably not signed with some official developer certificates, so you’ll get a message similar to this:

Run this setup anyway. In Windows 10 you will need to press “More info” link and the button “Run anyway” will appear:

After running the setup anyway, you should see a welcome screen of the installer:

After pressing the “Next” button you will be presented with the license agreement:

After accepting the license and pressing the “Next” button you should see the screen with the custom setup. Here you can select the components that are going to be installed. You can choose a custom install location, as well, if you so choose:

The default option for components should be just fine. The location should be just fine too. But if you want to customize it – go for it. Press the “Next” button when you are done.

At this point, we should be ready to start the installation. Hit that “Install” button now:

Right as the installation begins, your Windows will probably ask you whether you want to allow this program to be installed:

Again, because this is an open-source community it does not have a registered publisher (opened issue). Allow the installation. You should see an installation progress right after that:

When the installation is done, you should see a final screen of the setup wizard indicating a successful installation:

Press “Finish” to close the installer.

Now you want to verify that the installation was successful and you have a correct version of the OpenJDK installed. For that close and re-open Git BASH.

Then type the same command again: $ java -version. You should see the output like that:

openjdk version "1.8.0_141-1-ojdkbuild"
OpenJDK Runtime Environment (build 1.8.0_141-1-ojdkbuild-b16)
OpenJDK 64-Bit Server VM (build 25.141-b16, mixed mode)

If you need to update the OpenJDK version, repeat the process and make sure you download the latest available version from the ojdkbuild open-source community page.

IntelliJ IDEA

Both Kotlin programming language and IntelliJ IDEA are developed by the same company – JetBrains. As you might have guessed, IntelliJ has some serious support for that language. The development environment and the programming language are both optimised to work well with each other.

Of course, you can use a plain-text editor and command-line Kotlin compiler. I highly recommend you use proper tools for the job. Don’t worry IntelliJ IDEA Community Edition is free to use and open-source. So you should have no trouble downloading, installing and using it indefinitely for anything you want, including commercial applications.

This tutorial assumes you are using IntelliJ IDEA Community Edition. If you have it installed and configured, you should skip this section. Otherwise, here we go:​​​​

First, download the community edition from the official JetBrains website.

Then, launch the downloaded installer. You will need to allow this installer to make changes to your device:

After allowing the setup to proceed, you should see the front screen of the installer:

Hit that “Next” button to get started!

On the next screen of the installer you will be able to customize the installation directory for IntelliJ. Choose what you will or leave the default configuration:

After proceeding to the next screen of the installer, you will be presented with some advanced installation options. About desktop shortcut and file associations: it is up to your preference.

Note that you will want to leave “Download and install JRE x86 by JetBrains” unchecked because you already have OpenJDK installed.

Next step will allow you to configure the name for the startup menu folder. Default name should be fine:

As you press that “Install” button you should see the installation progress:

When the installation is finished, you should be presented with the successful installation screen:

Now, let’s launch the IntelliJ IDEA and see if the installation went well.

IntelliJ will ask you if you want to import any settings from any previous installation, answer “Do not import settings.” Next IntelliJ will ask you to read and accept their privacy policy – do that.

IntelliJ will ask you what theme you want to use. This tutorial will use the Intellij, default light theme.

IntelliJ will ask you what default plugins you want to use. Leave everything as is and proceed to the next step. Finally, IntelliJ will ask you one last thing: what featured plugins you want to use. Leave everything as is and proceed to the next step.

At this point, you should see IntelliJ loading. As it has loaded, you should see the front screen, which allows you to create a project, import or open the existing one:

Creating a “Hello World” Application

That should be it for dependencies. I highly recommend creating a simple project in Kotlin to see that everything works as expected. Let’s do that right now:

Click on the Create New Project button on the IntelliJ front screen:

After clicking on the button, you should see the “Create New Project” screen:

Next, you need to select “Kotlin” project group on the left sidebar:

Then, you will need to select “Kotlin/JVM” project in the main area of the current screen. Press “Next” button to proceed from here.

It might have caught your attention already: there is no Project SDK selected:

We will need to help IntelliJ to find our OpenJDK installation. Hit that “New…” button:

Then, you will be presented with a dialog that allows you to select the home directory for your JDK:

Make sure to select the home directory of your OpenJDK installation. If you used the default installation directory, the next screenshot should match what you should have here:

After pressing the “OK” button, you should be back to the new project screen. The Project SDK should no longer be highlighted as an error.

As you can see the Project Location is C:Users<YOUR_USER>IdeaProjectsuntitled. Particularly the part IdeaProjects. That is supposed to be a home directory for all the projects created in IntelliJ IDEA. I discourage you from using that. In our industry, most of the developers, whom I have met, prefer to use C:Users<YOUR_USER>workspace as the home directory for any of their projects, no matter if they are IntelliJ-based or not.

So change “IdeaProjects” to “workspace” and change your Project name from “untitled” to “HelloKotlin.” Also, make sure the Project Location says C:Users<YOUR_USER>workspaceHelloKotlin too. You do not need to change anything else on this screen at this point.

You should see now:

As we are done filling the details of our new project, let’s click on that “Finish” button. IntelliJ will ask you if it should create a new directory for your project. Click on the “OK” button.

Now you should see the workspace of your project:

As this is your first run of Kotlin project in IntelliJ, it will take a minute or so to index all the Kotlin and Java standard libraries.

As soon as it has completed indexing, you should see the sidebar with your project structure:

Now we should create our small hello world application. It will consist of a single file with the main function. The main function is the entry point to any application in Kotlin. When you run the application, the main function gets executed.

To create a new file, expand HelloKotlin module in the project sidebar. If you do not see the sidebar like on the picture, press ALT + 1. Then select src directory inside of it. src directory is where the code resides in the default project structure created by IntelliJ. Here is what you should see at that point:

Now to create a new file press ALT + Insert while src directory is selected; alternatively, you could right-click on src directory to bring up the context menu, and the first submenu is New.

Anyways, you should see now this context menu (or submenu):

That menu allows you to type to filter the items. Start typing “kotlin” to try it out:

Now press Enter to start the creation of new “Kotlin File/Class.” Alternatively, instead of using the filter, you could have just clicked with your mouse on “Kotlin File/Class” or use arrows to select that option.

After initiating the creation of new kotlin file or class, you will see an appropriate dialog, which allows you to choose the kind of kotlin file you want to create and its name:

Now type the name of the kotlin file: “Application.” Leave kind as it is - “File.” Finally, press Enter or click on the “OK” button:

After creating the file, it should automatically open in the main workspace area in the IntelliJ:

Now, the easiest way to create the main function is to type main and press TAB:

After you press TAB, the main function will be auto-generated by IntelliJ. This feature of IntelliJ is called live templates. It allows to type much less, comes with helpful built-in templates, and allows to configure your templates. That is what you should see when the main function is generated:

Now, to print “Hello, Kotlin!” on the screen add the following to your main function:

To run the application press CTRL + SHIFT + F10 while code editor with Application.kt open is active. The application should compile and run. Shortly, you should see the desired output “Hello, Kotlin!”:

Now you should be set to use Koltin with IntelliJ on ​Windows.

Check out my free Ultimate Tutorial: Getting Started With Kotlin where you will build a real command-line application while learning all the features of Kotlin you will need to construct 80% of any application.

Copyright © 2017 - Oleksii Fedorov