# Libraries

A library is a collection of compiled code that you can add to your project. In IntelliJ IDEA, libraries can be defined at three levels: global (available for many projects), project (available for all modules within a project), and module (available for one module).

A Java library can include class files, archives and directories with class files as well as directories with native libraries `.dll`, `.so`, or `.jnilib`.

> **Note:**
> This information is valid for projects that are built with the native IntelliJ IDEA builder. If you're using a build tool, such as [Maven](maven-support.html) or [Gradle](gradle.html), make all changes using the build file.

If you want to create your own reusable Java library, create and build a Java project (for example, with Gradle or Maven) to produce a JAR, then add or declare that JAR as a dependency. Learn more from [Maven Getting Started Guide](https://maven.apache.org/guides/getting-started/index.html) (maven.apache.org) or [Building Java &amp; JVM
projects](https://docs.gradle.org/current/userguide/building_java_projects.html) (docs.gradle.org) for Gradle.

## Define a library

After you define a library and add it to module dependencies, the IDE will be supplying its contents to you as you write your code. IntelliJ IDEA will also use the code from the libraries to build and deploy your application.

> **Tip:**
> You can also create a new library from the JAR files located within a project content root. Select these files in the   Project tool window  (`Alt+1` (Windows), `⌘ 1` (macOS), `⌘ 1` (IntelliJ IDEA Classic (macOS)), `⌘ 1` (macOS System Shortcuts), `Alt+1` (XWin), `Alt+1` (GNOME), `Alt+1` (KDE), `Alt+1` (Emacs), `Alt+1` (Sublime Text), `⌘ 1` (Sublime Text (macOS)), `Ctrl+1` (NetBeans), `Ctrl+Alt+L` (Visual Studio), `⌘ ⌥ L` (Visual Studio (macOS)), `Alt+1` (Eclipse), `Alt+1` (Eclipse (macOS))) , and then select Add as Library from the context menu.

Procedure: Define a global library

1. In the main menu, go to `File | Project Structure` `Ctrl+Alt+Shift+S` (Windows), `⌘ ;` (macOS), `⌘ ;` (IntelliJ IDEA Classic (macOS)), `⌘ ⇧ Comma` (macOS System Shortcuts), `Ctrl+Alt+Shift+S` (XWin), `Ctrl+Alt+Shift+S` (GNOME), `Ctrl+Alt+Shift+S` (KDE), `Ctrl+Alt+Shift+S` (Emacs), `Ctrl+Alt+Shift+S` (Sublime Text), `⌘ ;` (Sublime Text (macOS)), `Ctrl+Alt+Shift+S` (NetBeans), `Ctrl+Alt+Shift+S` (Visual Studio), `⌘ ;` (Visual Studio (macOS)), `Ctrl+Alt+Shift+S` (Eclipse), `⌘ ;` (Eclipse (macOS)).

2. Under Platform Settings, select Global Libraries.

3. Click ![the Add button](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.expui.general.add.svg) and select one of the following:

* Select Java or Kotlin/JS to add a library from the files located on your computer.

* Select From Maven to [download a library from Maven](#download-libraries-from-maven).

![Defining a global library](https://resources.jetbrains.com.cn/help/img/idea/2026.2/define-global-library.png)

In this dialog, you can also: ![Add](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.expui.general.add.svg) [add classes to an existing library](#add_classes_to_libraries), ![Specify Documentation URL](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.toolbarDecorator.addLink.svg) [specify an external documentation URL](#add-library-docs), ![Exclude](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.modules.addExcludedRoot.svg) [exclude items from a library](#excluded_lib_items), or ![Remove](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.expui.general.remove.svg) remove a library.

References to global libraries are stored in the IDE [configuration directory](directories-used-by-the-ide-to-store-settings-caches-plugins-and-logs.html#config-directory) in `options | applicationLibraries.xml`.

Procedure: Define a project library

1. In the main menu, go to `File | Project Structure` `Ctrl+Alt+Shift+S` (Windows), `⌘ ;` (macOS), `⌘ ;` (IntelliJ IDEA Classic (macOS)), `⌘ ⇧ Comma` (macOS System Shortcuts), `Ctrl+Alt+Shift+S` (XWin), `Ctrl+Alt+Shift+S` (GNOME), `Ctrl+Alt+Shift+S` (KDE), `Ctrl+Alt+Shift+S` (Emacs), `Ctrl+Alt+Shift+S` (Sublime Text), `⌘ ;` (Sublime Text (macOS)), `Ctrl+Alt+Shift+S` (NetBeans), `Ctrl+Alt+Shift+S` (Visual Studio), `⌘ ;` (Visual Studio (macOS)), `Ctrl+Alt+Shift+S` (Eclipse), `⌘ ;` (Eclipse (macOS)).

2. Under Project Settings, select Libraries.

3. Click ![the Add button](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.expui.general.add.svg) and select one of the following:

* Select Java or Kotlin/JS to add a library from the files located on your computer.

* Select From Maven to [download a library from Maven](#download-libraries-from-maven).

![Defining a project library](https://resources.jetbrains.com.cn/help/img/idea/2026.2/define-project-library.png)

4. Select the module or modules to which you want to add the new library.

In this dialog, you can also: ![Add](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.expui.general.add.svg) [add classes to an existing library](#add_classes_to_libraries), ![Specify Documentation URL](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.toolbarDecorator.addLink.svg) [specify an external documentation URL](#add-library-docs), ![Exclude](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.modules.addExcludedRoot.svg) [exclude items from a library](#excluded_lib_items), or ![Remove](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.expui.general.remove.svg) remove a library.

References to project libraries are stored together with the project in the `.idea` folder in `libraries`.

Procedure: Add a library to module dependencies

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](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.expui.general.add.svg) button and select Library.

![Adding a new module library](https://resources.jetbrains.com.cn/help/img/idea/2026.2/add-new-module-lib.png)

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](https://resources.jetbrains.com.cn/help/img/idea/2026.2/add-new-module-lib2.png)

References to module libraries are stored in the module `.iml` file. This file is used for keeping module configuration. For more information about module files, refer to [Modules](creating-and-managing-modules.html).

Procedure: Download a library from Maven

1. In the main menu, go to `File | Project Structure` `Ctrl+Alt+Shift+S` (Windows), `⌘ ;` (macOS), `⌘ ;` (IntelliJ IDEA Classic (macOS)), `⌘ ⇧ Comma` (macOS System Shortcuts), `Ctrl+Alt+Shift+S` (XWin), `Ctrl+Alt+Shift+S` (GNOME), `Ctrl+Alt+Shift+S` (KDE), `Ctrl+Alt+Shift+S` (Emacs), `Ctrl+Alt+Shift+S` (Sublime Text), `⌘ ;` (Sublime Text (macOS)), `Ctrl+Alt+Shift+S` (NetBeans), `Ctrl+Alt+Shift+S` (Visual Studio), `⌘ ;` (Visual Studio (macOS)), `Ctrl+Alt+Shift+S` (Eclipse), `⌘ ;` (Eclipse (macOS)) and click Libraries to add a project library or Global Libraries to add a global library.

2. Click ![Add](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.expui.general.add.svg) and select From Maven.

3. In the next dialog, specify the library artifact. If you don't know its exact name, enter the keywords and click ![Search](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.actions.search.svg).

You can also specify another library location, and select whether you want to download transitive dependencies, source files, Javadoc files, or annotations.

![Downloading a library from Maven](https://resources.jetbrains.com.cn/help/img/idea/2026.2/projects_libraries.png)

IntelliJ IDEA will download the library from Maven or Nexus public repositories. You can also configure a [custom remote repository](#configure-custom-remote-repo).

Procedure: Add classes to a library

Once the library is added, you can add more classes to it:

1. In the main menu, go to `File | Project Structure`. Then click Global Libraries to modify a global library or Libraries to modify a project library.

To modify a module library, select `File | Project Structure` from the main menu and go to `Modules | Dependencies`.

Select the library that you want to modify and click ![Edit](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app-client.expui.general.edit.svg).

![Adding classes to a library](https://resources.jetbrains.com.cn/help/img/idea/2026.2/add_classes_to_lib.png)

2. Click ![the Add button](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.expui.general.add.svg) and select the classes you want to add in the dialog that opens.

For a Java library, these may be individual `class` and `java` files, directories and archives `jar` and `zip` containing such files,or directories with Java native libraries `.dll`, `.so` or `.jnilib`.

3. IntelliJ IDEA will analyze the selected files and folders, and automatically assign their contents to the appropriate library categories (Classes, Sources, Documentation, Native Library Locations, and so on).

When IntelliJ IDEA cannot guess the category (for example, when you select an empty folder), a dialog will be shown, in which you will be able to specify the category yourself.

Procedure: Include specific transitive dependencies

If you want to include only specific transitive dependencies, you can use the library properties editor.

1. In the main menu, go to `File | Project Structure` `Ctrl+Alt+Shift+S` (Windows), `⌘ ;` (macOS), `⌘ ;` (IntelliJ IDEA Classic (macOS)), `⌘ ⇧ Comma` (macOS System Shortcuts), `Ctrl+Alt+Shift+S` (XWin), `Ctrl+Alt+Shift+S` (GNOME), `Ctrl+Alt+Shift+S` (KDE), `Ctrl+Alt+Shift+S` (Emacs), `Ctrl+Alt+Shift+S` (Sublime Text), `⌘ ;` (Sublime Text (macOS)), `Ctrl+Alt+Shift+S` (NetBeans), `Ctrl+Alt+Shift+S` (Visual Studio), `⌘ ;` (Visual Studio (macOS)), `Ctrl+Alt+Shift+S` (Eclipse), `⌘ ;` (Eclipse (macOS)), and go to `Modules | Dependencies`.

2. Select the necessary Maven library and click ![Edit](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.expui.general.edit.svg).

3. In the next dialog, click Edit, and then click Configure next to the Include transitive dependencies option.

4. Select the dependencies you want to include in the library and click OK.

## Change the library level

Procedure: Move a library to a higher level

In IntelliJ IDEA, you can move a project or a module library to a higher level. This is helpful if you want to extend its scope of usage. For example, use this procedure if you want to use a module library across the project or the entire IDE.

1. In the main menu, go to `File | Project Structure` `Ctrl+Alt+Shift+S` (Windows), `⌘ ;` (macOS), `⌘ ;` (IntelliJ IDEA Classic (macOS)), `⌘ ⇧ Comma` (macOS System Shortcuts), `Ctrl+Alt+Shift+S` (XWin), `Ctrl+Alt+Shift+S` (GNOME), `Ctrl+Alt+Shift+S` (KDE), `Ctrl+Alt+Shift+S` (Emacs), `Ctrl+Alt+Shift+S` (Sublime Text), `⌘ ;` (Sublime Text (macOS)), `Ctrl+Alt+Shift+S` (NetBeans), `Ctrl+Alt+Shift+S` (Visual Studio), `⌘ ;` (Visual Studio (macOS)), `Ctrl+Alt+Shift+S` (Eclipse), `⌘ ;` (Eclipse (macOS)) and locate the library that you want to change.

2. Right-click the necessary library and select Move to Project Libraries or Move to Global Libraries.

![Moving a module library to a higher level](https://resources.jetbrains.com.cn/help/img/idea/2026.2/change-lib-level.png)

Procedure: Copy a library to a lower level

You can create a copy of a library on a lower level. For example, use this procedure if you want to add more classes to a project library, but you want to use them in one module only.

1. In the main menu, go to `File | Project Structure` `Ctrl+Alt+Shift+S` (Windows), `⌘ ;` (macOS), `⌘ ;` (IntelliJ IDEA Classic (macOS)), `⌘ ⇧ Comma` (macOS System Shortcuts), `Ctrl+Alt+Shift+S` (XWin), `Ctrl+Alt+Shift+S` (GNOME), `Ctrl+Alt+Shift+S` (KDE), `Ctrl+Alt+Shift+S` (Emacs), `Ctrl+Alt+Shift+S` (Sublime Text), `⌘ ;` (Sublime Text (macOS)), `Ctrl+Alt+Shift+S` (NetBeans), `Ctrl+Alt+Shift+S` (Visual Studio), `⌘ ;` (Visual Studio (macOS)), `Ctrl+Alt+Shift+S` (Eclipse), `⌘ ;` (Eclipse (macOS)) and locate the library that you want to change.

2. Right-click the necessary library and select Copy to Project Libraries or Add to Modules.

![Copying a global library to a lower level](https://resources.jetbrains.com.cn/help/img/idea/2026.2/move-lib-lower.png)

## Exclude library items

IntelliJ IDEA allows you to temporarily exclude library items in order to increase IDE performance. You can exclude folders, archives (for example, JARs) and folders within archives.

Classes from excluded packages won't be shown in code completion suggestion lists, references to such classes will be shown in the editor as unresolved, and so on. However, when you compile or run your code, a library will still be used as a whole, irrespective of whether there are excluded items in that library or not.

Procedure: Exclude items from a project or a global library

1. In the main menu, go to `File | Project Structure` `Ctrl+Alt+Shift+S` (Windows), `⌘ ;` (macOS), `⌘ ;` (IntelliJ IDEA Classic (macOS)), `⌘ ⇧ Comma` (macOS System Shortcuts), `Ctrl+Alt+Shift+S` (XWin), `Ctrl+Alt+Shift+S` (GNOME), `Ctrl+Alt+Shift+S` (KDE), `Ctrl+Alt+Shift+S` (Emacs), `Ctrl+Alt+Shift+S` (Sublime Text), `⌘ ;` (Sublime Text (macOS)), `Ctrl+Alt+Shift+S` (NetBeans), `Ctrl+Alt+Shift+S` (Visual Studio), `⌘ ;` (Visual Studio (macOS)), `Ctrl+Alt+Shift+S` (Eclipse), `⌘ ;` (Eclipse (macOS)) and click Libraries.

2. Click ![Exclude](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.modules.addExcludedRoot.svg) and select the library items that you want to exclude.

Procedure: Exclude items from a module library

1. In the main menu, go to `File | Project Structure` `Ctrl+Alt+Shift+S` (Windows), `⌘ ;` (macOS), `⌘ ;` (IntelliJ IDEA Classic (macOS)), `⌘ ⇧ Comma` (macOS System Shortcuts), `Ctrl+Alt+Shift+S` (XWin), `Ctrl+Alt+Shift+S` (GNOME), `Ctrl+Alt+Shift+S` (KDE), `Ctrl+Alt+Shift+S` (Emacs), `Ctrl+Alt+Shift+S` (Sublime Text), `⌘ ;` (Sublime Text (macOS)), `Ctrl+Alt+Shift+S` (NetBeans), `Ctrl+Alt+Shift+S` (Visual Studio), `⌘ ;` (Visual Studio (macOS)), `Ctrl+Alt+Shift+S` (Eclipse), `⌘ ;` (Eclipse (macOS)) and select `Modules | Dependencies`.

2. Select the library that you want to modify and click ![Edit](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app-client.expui.general.edit.svg).

3. Click ![Exclude](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.modules.addExcludedRoot.svg) and select the library items that you want to exclude.

Excluded items will be marked with the ![Excluded root](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.modules.excludeRoot.svg) icon. To return library items to their original state, remove the excluded items.

## Configure a custom remote repository

Procedure:

You can view the full list of remote repositories and add a custom repository in the settings. Note that IntelliJ IDEA can load libraries from Maven even if you don't use Maven as a build tool for your project.

1. In the Settings dialog `Ctrl+Alt+S` (Windows), `⌘ Comma` (macOS), `⌘ Comma` (IntelliJ IDEA Classic (macOS)), `⌘ Comma` (macOS System Shortcuts), `Ctrl+Alt+S` (XWin), `Ctrl+Alt+S` (GNOME), `Ctrl+Alt+S` (KDE), `Ctrl+Alt+S` (Emacs), `Ctrl+Alt+S` (Sublime Text), `⌘ Comma` (Sublime Text (macOS)), `Ctrl+Alt+S` (NetBeans), `Ctrl+Alt+S` (Visual Studio), `⌘ Comma` (Visual Studio (macOS)), `Ctrl+Alt+S` (Eclipse), `⌘ Comma` (Eclipse (macOS)), go to `Build, Execution, Deployment | Remote Jar Repositories`.

2. Click Add in the corresponding dialog section, and specify the repository URL.

## Configure library documentation

You can add library documentation to IntelliJ IDEA so that you can get information about symbols and method signatures right from the editor in the [Quick Documentation](viewing-reference-information.html#inline-quick-documentation) popup.

You can also configure external documentation by specifying the path to the reference information online. External documentation opens the necessary information in a browser so that you can navigate to related symbols and keep the information for further reference at the same time.

> **Tip:**
> If you are [downloading a library from Maven](#download-libraries-from-maven), select the JavaDoc checkbox to get the library documentation together with the library code.

Procedure: Specify library documentation paths

To view external library documentation, configure the documentation URL first.

1. Open the Project Structure dialog (`Ctrl+Alt+Shift+S` (Windows), `⌘ ;` (macOS), `⌘ ;` (IntelliJ IDEA Classic (macOS)), `⌘ ⇧ Comma` (macOS System Shortcuts), `Ctrl+Alt+Shift+S` (XWin), `Ctrl+Alt+Shift+S` (GNOME), `Ctrl+Alt+Shift+S` (KDE), `Ctrl+Alt+Shift+S` (Emacs), `Ctrl+Alt+Shift+S` (Sublime Text), `⌘ ;` (Sublime Text (macOS)), `Ctrl+Alt+Shift+S` (NetBeans), `Ctrl+Alt+Shift+S` (Visual Studio), `⌘ ;` (Visual Studio (macOS)), `Ctrl+Alt+Shift+S` (Eclipse), `⌘ ;` (Eclipse (macOS))) and go to Libraries.

2. Select a library from the list and click ![](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.toolbarDecorator.addLink.svg) Specify Documentation URL in the right section of the dialog.

3. In the dialog that opens, enter the documentation URL and click OK.

![Specifying the library documentation path in the Project Structure dialog](https://resources.jetbrains.com.cn/help/img/idea/2026.2/external-lib-docs-url.png)

4. Apply the changes and close the dialog.

Procedure: Add library documentation to your project

You can add downloaded documentation to your project to be able to access it offline.

1. Open the Project Structure dialog (`Ctrl+Alt+Shift+S` (Windows), `⌘ ;` (macOS), `⌘ ;` (IntelliJ IDEA Classic (macOS)), `⌘ ⇧ Comma` (macOS System Shortcuts), `Ctrl+Alt+Shift+S` (XWin), `Ctrl+Alt+Shift+S` (GNOME), `Ctrl+Alt+Shift+S` (KDE), `Ctrl+Alt+Shift+S` (Emacs), `Ctrl+Alt+Shift+S` (Sublime Text), `⌘ ;` (Sublime Text (macOS)), `Ctrl+Alt+Shift+S` (NetBeans), `Ctrl+Alt+Shift+S` (Visual Studio), `⌘ ;` (Visual Studio (macOS)), `Ctrl+Alt+Shift+S` (Eclipse), `⌘ ;` (Eclipse (macOS))) and go to Libraries.

2. Select a library from the list and click ![](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.expui.general.add.svg) Add in the right section of the dialog.

![Adding library documentation with a file in the Project Structure dialog](https://resources.jetbrains.com.cn/help/img/idea/2026.2/add-library-docs.png)

3. In the dialog that opens, select the JAR file that includes the documentation and click Open.

4. Apply the changes and close the dialog.

When the documentation is configured, you can [open it in the editor](viewing-reference-information.html#inline-quick-documentation).

## See also

### Procedures

[Module dependencies](working-with-module-dependencies.html) [Configure JavaScript libraries](configuring-javascript-libraries.html) [Package an application into a JAR](compiling-applications.html#package_into_jar)

