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:

./projectname.iml
./projectname.ipr
./projectname.iws
./src/

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?


Steps for adding external jars in IntelliJ IDEA:

  • Click File from the toolbar
  • Project Structure (CTRL + SHIFT + ALT + S on Windows/Linux, ⌘ + ; on Mac OS X)
  • Select Modules at the left panel
  • Dependencies tab
  • '+' → JARs or directories

  • IntelliJ IDEA 15 & 2016

  • File > Project Structure...

    or press Ctrl + Alt + Shift + S

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

    模块>依赖> JAR或目录

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

    在这里输入图像描述

  • You can view the jar file in the "External Libraries" folder


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

    链接地址: http://www.djcxy.com/p/29674.html

    上一篇: Maven模块+构建单一特定模块

    下一篇: 将外部jar(lib / *。jar)添加到IntelliJ IDEA项目的正确方法