IntelliJ IDEA 2024.3 Help

Module structure settings

Module settings apply only to one module and are stored in the .iml file. A module can have an SDK and a language level that are different from those configured for a project, and their own libraries. They can also carry a specific technology or a framework.

Module SDK

An SDK is a collection of tools that you need to develop an application for a specific software framework. To develop Java-based applications, you need a JDK (Java Development Kit).

You can compile a module with an SDK that differs from the project SDK.

Add a module SDK

  1. In the main menu, go to File | Project Structure | Project Settings | Modules.

  2. Select the module for which you want to set an SDK and click Dependencies.

  3. If the necessary SDK is already defined in IntelliJ IDEA, select it from the Detected SDKs list.

  4. Only for JDKs: if the IDE cannot find the necessary JDK on your computer automatically, click Add JDK from disk and specify its home directory in the dialog that opens.

    If you don't have the necessary JDK on your computer, select Download JDK. In the next dialog, specify the JDK vendor, version, change the installation path if required, and click Download.

Setting up another module-level SDK

How does IntelliJ IDEA know which JDK to use?

IntelliJ IDEA does the following to determine which JDK to use for compilation if you use different JDKs for modules in your project.

  • It checks all JDKs that are used in the project: the JDKs that are defined on both the project and module levels.

  • It calculates the latest of these JDKs. This is necessary to make sure all modules can be compiled.

  • If the version of the latest JDK configured is lower than 1.6, IntelliJ IDEA will pick the JDK version that is used for running the IDE. This limitation is related to the fact that the compiler API used by IntelliJ IDEA for building projects is supported starting from JDK 1.6.

  • Although a specific version of the compiler will be used (in accordance with the selected JDK version), each separate module will be compiled using the javac's cross-compilation feature against the libraries of the JDK defined for this particular module in the project settings.

    This protects you from a situation when a module is compiled against newer libraries than those for which dependencies are set.

Module language level

Language level defines coding assistance features that the editor provides. To configure a language level for a module:

Configure module language level

  1. In the main menu, go to File | Project Structure Ctrl+Alt+Shift+S.

  2. Under Project Settings, select Modules | Sources.

  3. From the Language level list, select the necessary option.

  4. To use the project language level, select Project default.

Specifying the module language level

Module compiler output

Compiler output path is the path to the directory in which IntelliJ IDEA stores the compilation results. In this directory, the IDE creates two sub-directories: output for production code and test output for test sources.

Configure module compiler output

  1. In the main menu, go to File | Project Structure Ctrl+Alt+Shift+S.

  2. Under Project Settings, select Modules | Paths.

  3. Change the paths specified in the Output path and Test output path or select Inherit project compile output path to use the paths specified for the project.

  4. Select the Exclude output path checkbox to exclude the output folders from code completion, navigation, and inspections. This helps increase overall IDE performance.

Specifying module compiler output

Module libraries

Libraries are a collection of compiled code that you can use when developing applications. You can add libraries on the module level. In this case, only one module can use the code from such libraries.

Add module-level libraries

Global and project libraries are not available until you add them to module dependencies.

  1. In the main menu, go to File | Project Structure | Project Settings | Modules.

  2. Select the module for which you want to add a library and click Dependencies.

  3. Click the Add button and select Library.

    Adding a new module library
  4. In the dialog that opens, select a project or a global library that you want to add to the module.

    Alternatively, click New Library and select the required option: you can add a Java and Kotlin libraries from files on your computer, or download a library from Maven.

    Adding a new module library
Last modified: 04 July 2024