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

2021-6-3 anglehua

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?

dialogue in Intellij 20.3

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

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


Powered by emlog 京ICP备15036472号-3 sitemap