Ask Sawal

Discussion Forum
Notification Icon1
Write Answer Icon
Add Question Icon

How to run kt file in intellij?

3 Answer(s) Available
Answer # 1 #
  • From the File menu, select New, and then click Scratch File.
  • Press ⇧⌘N (Shift + Command +N)
  • Using find action (Press ⇧⌘A), start typing scratch file and then pick the corresponding action.
Busby Friedenberg
Petroleum Geologist
Answer # 2 #

Many IDEs are available to choose from, for Kotlin project development. IntelliJ has been responsible for the development of Kotlin programming language. So, we pick IntelliJ IDEA for Kotlin programming.

In this tutorial, we shall learn to set up a Kotlin Java Project in IntelliJ IDEA, in a step by step process.

First of all, you need to have IntelliJ IDEA setup in your computer. If you don’t have the setup, latest Community Edition is available at  []. Download the IDE and follow the instructions for installation.

Once you are ready with the IntelliJ IDEA Community Edition, start IntelliJ IDEA. A welcome window should appear with an option to Create New Project.

Click on the “Create New Project” button. It takes to a New Project window. By default, on the left pane, you may find Java, Java FX, Android etc. Select Java. In the “Additional Libraries and Frameworks” section, check “Kotlin(Java)”. Leave other options to their defaults. Click on Next.

Give your project a name, “KotlinTutorial” and choose a location for the project to be created in, as per you choice.

Click on Finish.

If Project window is not visible, hit Alt+1. Expand the project. “src” project should be there in the Project. Now, right click on “src” folder -> New -> Kotlin File/Class.

Give a name, “hello_world” and click on “OK”

Write the main method and hit Run-> Run. The Kotlin compiles and runs the project. The message “Hello, world!” is printed to the output as shown in the below screenshot.

Angelababy Gillette
Space Nursing
Answer # 3 #

The easiest way to get started with Kotlin, is to use an IDE.

An IDE (Integrated Development Environment) is used to edit and compile code.

In this chapter, we will use IntelliJ (developed by the same people that created Kotlin) which is free to download from

Once IntelliJ is downloaded and installed, click on the New Project button to get started with IntelliJ:

Then click on "Kotlin" in the left side menu, and enter a name for your project:

Next, we need to install something called JDK (Java Development Kit) to get our Kotlin project up and going. Click on the "Project JDK" menu, select "Download JDK" and select a version and vendor (e.g. AdoptOpenJDK 11) and click on the "Download" button:

When the JDK is downloaded and installed, choose it from the select menu and then click on the "Next" button and at last "Finish":

Now we can start working with our Kotlin project. Do not worry about all of the different buttons and functions in IntelliJ. For now, just open the src (source) folder, and follow the same steps as in the image below, to create a kotlin file:

Select the "File" option and add a name to your Kotlin file, for example "Main":

You have now created your first Kotlin file (Main.kt). Let's add some Kotlin code to it, and run the program to see how it works. Inside the Main.kt file, add the following code:

Don't worry if you don't understand the code above - we will discuss it in detail in later chapters. For now, lets focus on how to run the code. Click on the Run button at the top navigation bar, then click "Run", and select "Mainkt".

Next, IntelliJ will build your project, and run the Kotlin file. The output will look something like this:

As you can see, the output of the code was "Hello World", meaning that you have now written and executed your first Kotlin program!

When learning Kotlin at, you can use our "Try it Yourself" tool, which shows both the code and the result. This will make it easier for you to understand every part as we move forward:

Shiney Kagne