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

后端 未结 9 1498
时光取名叫无心
时光取名叫无心 2020-11-21 10:20

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

./projectname.iml
./projectname.ipr
./projectname.iws
./s         


        
相关标签:
9条回答
  • 2020-11-21 10:42

    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

    0 讨论(0)
  • 2020-11-21 10:46

    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
    0 讨论(0)
  • 2020-11-21 10:52

    Libraries cannot be directly used in any program if not properly added to the project gradle files.

    This can easily be done in smart IDEs like inteli J.

    1) First as a convention add a folder names 'libs' under your project src file. (this can easily be done using the IDE itself)

    2) then copy or add your library file (eg: .jar file) to the folder named 'libs'

    3) now you can see the library file inside the libs folder. Now right click on the file and select 'add as library'. And this will fix all the relevant files in your program and library will be directly available for your use.

    Please note:

    Whenever you are adding libraries to a project, make sure that the project supports the library

    0 讨论(0)
提交回复
热议问题