Correct way to add external jars (lib/*.jar) to an IntelliJ IDEA project


When creating a new Java project in IntelliJ IDEA, the following directories and files are created:


I want to configure IntelliJ IDEA to include my dependency JARs in ./lib/*.jar to the project. What is the correct way to achieve this in IntelliJ IDEA?


1 comment

You need to define it as a Project Library in Project Structure dialog and then add this library as a dependency to a module.

But the recommended approach is to use Maven or Gradle for managing dependencies. IDE provides corresponding project template for Java Gradle or Maven based projects, so you may use the corresponding project template type for this.

Then, to use the jars from your local ./lib/*.jar folder in Maven, these jars need to be added Maven local repository, see

Btw .ipr .iws files are legacy project configuration files format. It is recommended to use new project-based format for configuration files.


Please sign in to leave a comment.