IntelliJ IDEA 2024.3 Help

Add items to your project

Once you have created a project, you can start adding new items: create directories and packages, add new classes, import resources, and extend your project by adding more modules.

Create new items

Create a new directory

  1. In the Project tool window (Alt+1), right-click the node in which you want to create a new directory and select New | Directory.

    Alternatively, select the node, press Alt+Insert, and click Directory.

  2. Name the new directory and press Enter.

    If you want to create several nested directories, specify their names separated with slashes, for example: folder/new-folder.

    Creating a new directory

Create a new package

Packages in Java are used for grouping classes that belong to the same category or provide similar functionality, for structuring and organizing large applications with hundreds of classes.

  1. In the Project tool window (Alt+1), right-click the node within the Sources Root the Sources root icon or Test Sources Root the Test Sources root in which you want to create a new package, and click New | Package.

    Alternatively, select the node, press Alt+Insert, and click Package.

  2. Name the new package and press Enter.

    Write package names in lowercase letters. There are some other naming conventions for packages in Java that you should follow.

    Creating a new Java package

Create a new empty file

  1. In the Project tool window (Alt+1), right-click the node in which you want to create a new file and click New | File.

    Alternatively, select the node, press Alt+Insert, and click File.

  2. Name the new file and specify its extension, for example: File.js, and press Enter.

    If the extension you have specified is not associated with any of the file types recognized by IntelliJ IDEA, the Register New File Type Association dialog is displayed. In this dialog, you can associate the extension with one of the recognized file types.

Create a new Java class

  1. In the Project tool window (Alt+1), right-click the node in which you want to create a new class and select New | Java Class.

    Alternatively, select the node, press Alt+Insert, and select Java Class.

  2. Name the new class and press Enter.

    Follow the Java naming convention as you create new classes.

Together with the file, IntelliJ IDEA automatically generates the class declaration.

This is done by means of file templates. Depending on the type of the file that you create, the IDE inserts initial code and formatting that is expected to be in all files of that type. For more information about how to use and configure templates, refer to File templates.

Create a new module

Modules allow you to combine several technologies and frameworks in one application. In IntelliJ IDEA, you can create several modules in one project and each of them can be responsible for its own framework.

  1. Select the top-level directory in the Project tool window and press Alt+Insert or select New | Module from the context menu.

    The New Module wizard opens.

  2. From the list on the left, select the language that you want to use in your application.

    If you want to use a language that is not available in IntelliJ IDEA out of the box (for example, Python or PHP), click More via plugins and select the necessary option.

    The IDE will open a dialog in which you can select and install the necessary language plugin. After that, you can close the dialog and keep configuring the new project.

  3. Name the new module.

  4. Select the build system that you want to use in your project: the native IntelliJ builder, Maven, or Gradle.

    For Gradle, you will also need to select a language for the build script: Groovy or Kotlin.

  5. Select a JDK that you want to use from the JDK list. You can use the project SDK or specify a new one.

  6. Click Create.

For more information about modules in IntelliJ IDEA, refer to Modules.

Import items

Import files

You can import files to your project using any of the following ways:

  • Drag the file from your system file manager to the necessary node in the Project tool window (Alt+1).

  • Copy the file in the system file manager by pressing Ctrl+C and then paste in to the necessary node in the IDE Project tool window by pressing Ctrl+V.

  • Manually move the file to the project folder in your system file manager.

Import folders

  • To import a folder to your current project, drag the folder from your system file manager to the Project tool window (Alt+1).

Import an existing module

You can import a module to your project by adding the .iml file from another project:

  1. In the main menu, go to File | New | Module from Existing Sources.

  2. In the dialog that opens, specify the path the .iml file of the module that you want to import, and click Open.

    By doing so, you are attaching another module to the project without physically moving any files. If you don't need the modules to be located in one folder, the module import is finished, and you can start working with the project normally.

For more information about modules in IntelliJ IDEA, refer to Modules.

Last modified: 11 February 2024