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?

12/28/2015 3:03:40 PM

Accepted Answer

Steps for adding external jars in IntelliJ IDEA:

  1. Click File from the toolbar
  2. Select Project Structure option (CTRL + SHIFT + ALT + S on Windows/Linux, + ; on Mac OS X)
  3. Select Modules at the left panel
  4. Select Dependencies tab
  5. Select + icon
  6. Select 1 JARs or directories option
7/14/2020 4:31:06 PM

IntelliJ IDEA 15 & 2016

  1. File > Project Structure...

    File > Project Structure

    or press Ctrl + Alt + Shift + S

  2. Project Settings > Modules > Dependencies > "+" sign > JARs or directories...

    Modules > Dependencies > JAR or directories

  3. Select the jar file and click on OK, then click on another OK button to confirm

    enter image description here

    enter image description here

  4. You can view the jar file in the "External Libraries" folder

    enter image description here


Just copy-paste the .jar under the "libs" folder (or whole "libs" folder), right click on it and select 'Add as library' option from the list. It will do the rest...

enter image description here


You add them as libraries to your module.

I usually have a /lib directory in my source. I put all the JARs I need there, add /lib as a library, and make it part of my module dependencies.

2018 update: I'm using IntelliJ 2017/2018 now.

I'm fully committed to Maven and Nexus for dependency management.

This is the way the world has gone. Every open source Java project that I know of uses Maven or Gradle. You should, too.


If you are building your project with gradle, you just need to add one line to the dependencies in the build.gradle:

buildscript {

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])

and then add the folder to your root project or module:

enter image description here

Then you drop your jars in there and you are good to go :-)


I use this method and it works well:

1- Copy And paste the .jar files under the libs folder.

2- Add compile fileTree(dir: 'libs', include: '*.jar') to dependencies in build.gradle then all the jars in the libs folder will be included..

3- Right click on libs folder and select 'Add as library' option from the list.