[Use of Java development tools] Three ways to add jar packages in Intellij IDEA



1. Direct copy: (Not recommended)
Method: Copy and paste the jar package on the hard disk directly into the lib directory of the project.


Note:
1. For the imported eclipse project , the jar package added in this way has no response , and compiling the project with make will report an error
2. For the project created in idea, this way to add the jar package, compile without error, but open Structure will There is a "...jar ... is missing ..." prompt, which needs to be solved by clicking "Fix" or the red light bulb .

 


2. Add through the Dependencies of Modules: (recommended)
1. Open File -> Project Structure (Ctrl + Shift + Alt + S)

 
2. Click Modules -> Dependencies -> "+" -> "Jars or directories"

 

 
3. Select the jar package on the hard disk
4.Apply -> OK


3. Add via Libraries: (strongly recommended)
1. Open File -> Project Structure (Ctrl + Shift + Alt + S)


 

For the newly imported project, the relevant jar packages in the lib directory will be automatically imported. We need to delete these automatically added jar packages, as shown in the figure:



 

 

 
2. Click Libraries -> "+" -> "Java" -> select the main directory of the project we imported and click OK




 


 
Note: Click "Cancel" in the pop-up box to cancel adding it to the Module



 
At this point, the lib directory is created successfully, delete the redundant content added in the directory, and re-add the required jar package



 

 

 

 

At this point, Libraries have been created successfully.

 

3. Go back to the Modules menu, select the previously imported project, click "Dependencies", click "+" -> "Library", and add the Library directory you just created.



 

 

 

4. Add other jar packages (such as tomcat related jar packages ) that are not in the lib directory of the project in this way.



 

 

At this point, all jar packages have been added successfully!



Note:
1. The difference between icons:

   One is to add the icon of the jar package in the lib directory of the project, like a folder ;

   One is a jar package added in other directories, like a histogram .

2. To add a new jar package in the future , just add it to the lib directory of the previously created project in the Library directory .

 

 

Related links:
Directly copying jar to lib in IDEA is invalid
IDEA The correct way to add all jar packages in the lib directory



Disclaimer: Thank you blogger for your ideas! http://zyjustin9.iteye.com/blog/2172445

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324883717&siteId=291194637