- Open the module settings and select the Dependencies tab.
- On the Dependencies tab, click
and
select
Jars or directories. - In the dialog that opens, select the necessary files and folders. These may be individual .class, .java, .jar and .zip files, and the directories containing such files. Click OK.
- If necessary, select the Export option and change the dependency scope.
- Click OK in the Project Structure dialog.
- Open the module settings and select the Dependencies tab.
- On the Dependencies tab, click
and
select
Library. - In the Choose Libraries dialog, select one or more libraries and click Add Selected.
Note
The libraries you can choose from include:
- Global libraries
- Project libraries existing in the current project
- Application server libraries for the servers registered in IntelliJ IDEA.
- If necessary, select the Export option and change the dependency scope.
- Click OK in the Project Structure dialog.
- Open the module settings and select the Dependencies tab.
- On the Dependencies tab, click
and
select
Library. - In the Choose Libraries dialog, click New Library.
- If suggested, select:
- Java to create a Java library. Select the files and folders containing the library resources in the dialog that opens.
- From Maven to download a Java library from a public
Maven repository
.
Specify the artifact to be downloaded and the associated settings in the
Download Library from Maven Repository dialog.
- In the Configure Library dialog:
- Specify the library name.
- Select the library level (global, project or module).
- Configure the library contents using
and
. - Click OK.
- In the Choose Libraries dialog, click Add Selected.
- If necessary, select the Export option and change the dependency scope.
- Click OK in the Project Structure dialog.
Sometimes, you don't need to open the Project Structure dialog to create a new library and add it to the dependencies of a module. This is the case when there are .jar files within your project content roots.
You can select such .jar files in the Project tool window and use these files to create a library. When doing so, you will be able to select the library level and the module that should depend on the library that you are creating.
In a similar way, you can use a directory containing .jar files to create a library.
- Open the Project tool window.
- Select the .jar file or files to be included in the library, or a directory that contains the .jar files of interest.
- Select Add as Library from the context menu.
- In the Create Library dialog, specify the library name, level and the module that should depend on this library.
- Open the module settings and select the Dependencies tab.
- On the Dependencies tab, click
and
select
Module Dependency. - In the Choose Modules dialog, select one or more modules the current one should depend on, and click OK.
Note
Your selection is limited to the modules of the current project. That is, you cannot select the modules from a different project.
- If necessary, select the Export option and change the dependency scope.
- Click OK in the Project Structure dialog.
In certain cases, the order of module dependencies may be important, see Processing Order.
To reorder the items, use
and
.
Clicking these icons moves the selected item one line up or down in the list.
- Open the module settings and select the Dependencies tab.
- On the Dependencies tab, select the library whose contents you want to configure,
and click
. - Use
and
to manage the library contents.
For more information, see Configure Library Dialog and Project Library and Global Library Pages. - Click OK in the Project Structure dialog.
- Open the module settings and select the Dependencies tab.
- On the Dependencies tab, right-click the library of interest, and select Move to Project Libraries or Move to Global Libraries.
- In the Move Library dialog, if necessary, edit the library name. If you want to change the location of the library files, select the Move library files to check box and specify the corresponding location.
Note that the corresponding library is not removed from the list of the module dependencies.
Tip
If while exploring code you've encountered a class with the missing sources, it is not a problem. With IntelliJ IDEA, you can attach sources "on the fly": having detected missing sources, IntelliJ IDEA displays a banner, and suggests to download the missing sources from oss.sonatype.org, and attach them to your libraries.

