Kotlin Help

Create your first Kotlin Notebook

You can start working with your Kotlin Notebook in three main ways:

Create a new project

To create a new project that includes a Kotlin Notebook:

  1. In IntelliJ IDEA's welcome screen, select Kotlin Notebook | New Notebook from the panel on the left.

  2. Enter a Name for your new notebook and select Type | In Folder.

    • Scratch: This option is to create a scratch notebook without adding it to a project.

    • In Folder: This option is to create a notebook within a project. You have to specify the project's location.

  3. Click Create.

Create a new Kotlin Notebook from IntelliJ IDEA

Your new Kotlin Notebook is created within a new project.

Alternatively, create an empty project and then add a Kotlin Notebook:

  1. In IntelliJ IDEA, select File | New | Project.

  2. In the panel on the left, select New Project.

  3. Name the new project and change its location if necessary.

  4. From the Language list, select Kotlin.

    Create a new Kotlin Notebook project
  5. Select the IntelliJ build system.

  6. From the JDK list, select the JDK that you want to use in your project.

  7. Enable the Add sample code option to create a file with a sample "Hello World!" application.

  8. Click Create.

Once your project is created, add a new Kotlin Notebook (see the next section).

Add a new Kotlin Notebook to your project

To add a new Kotlin Notebook to an existing project:

  1. Select File | New | Kotlin Notebook, or right-click on a folder and select New | Kotlin Notebook.

    Create a new Kotlin Notebook
  2. Set the name of the new notebook, for example, first-notebook.

  3. Press Enter. A new tab with a Kotlin Notebook first-notebook.ipynb opens.

Create a scratch Kotlin Notebook

You can also create a Kotlin Notebook as a scratch file. Scratch files allow you to test small pieces of code without creating a new project or modifying an existing one.

To create a scratch Kotlin Notebook:

  1. Click File | New | Scratch File.

  2. Select Kotlin Notebook from the New Scratch File list.

    Scratch notebook

Perform basic operations

  1. In the new Kotlin Notebook, type the following code in the code cell:

    println("Hello, this is a Kotlin Notebook!")
  2. To run a code cell, click the Run Cell and Select Below Run Cell and Select Below button or press Shift + Return.

  3. Add a markdown cell by clicking on the Add Markdown Cell button.

  4. Type # Example operations in the cell, and run it the same way you run code cells to render it.

  5. In a new code cell, type 10 + 10 and run it.

  6. Define a variable in a code cell. For example, val a = 100.

  7. Create a new code cell and add println(a * a).

  8. Run all code and markdown cells in the notebook using the Run All Run all button button.

    First notebook

Congratulations! You have just created and tried out your first Kotlin Notebook.

Next step

In the next part of the tutorial, you will learn how to add dependencies to a Kotlin Notebook.

Proceed to the next chapter

17 October 2025