- Kotlin Programming By Example
- Iyanu Adelekan
- 264字
- 2025-04-04 17:16:16
Setting up a Kotlin project with IntelliJ
The process of setting up a Kotlin project with IntelliJ is straightforward:
- Start the IntelliJ IDE application.
- Click Create New Project.
- Select Java from the available project options on the left-hand side of the newly opened window.
- Add Kotlin/JVM as an additional library to the project.
- Pick a project SDK from the drop-down list in the window.
- Click Next.
- Select a template if you wish to use one, then continue to the next screen.
- Provide a project name in the input field provided. Name the project HelloWorld for now.
- Set a project location in the input field.
- Click Finish.
Your project will be created and you will be presented with the IDE window:

To the left of the window, you will immediately see the project view. This view shows the logical structure of your project files.
Two folders are present. These are:
- .idea: This contains IntelliJ's project-specific settings files.
- src: This is the source folder of your project. You will place your program files in this folder.
Now that the project is set up, we will write a simple program. Add a file named hello.kt to the source folder (right-click the src folder, select New | Kotlin File/Class, and name the file hello). Copy and paste the following code into the file:
fun main(args: Array<String>) {
println("Hello world!")
}
To run the program, click the Kotlin logo adjacent to the main function and select Run HelloKt:

The project will be built and run, after which, Hello world! will be printed to the standard system output.