Method 1:
Right-click your project directory and choose Properties From the shortcut menu]PropertiesAnd then select [Java build path]JavaBuildPath, The third item on the right tab [database]LibrariesAnd click Add jars on the right]AddJars
Or select the second [add external jars]AddExternalJarsFind the jar package to be added and add it;
Method 2:
One disadvantage of adding an external jar package is that when our project is moved to another directory, or we often need to move the project to another machine for running, after re-importing the project, you will find that the original jar package cannot be found. Sometimes we want to use the jar package as a part of the project, move it as the project moves, and find these jar packages after moving.
In a web project, you can directly copy the jar package to be imported to the WEB-INF/lib folder under your project, and the program can run normally when it is moved to another machine.
If it is a common Java project, we can create a new Lib folder in the project folder and put all the jar packages we need into the Lib folder,Remember to refresh the project in eclipseSo that the project can identify the newly created lib folder. Then use the method in method 1 to openJavaBuildPath, ClickAdd
JarsSelect all the jar packages in the Lib folder.
Method 3:
First use method 2 and then use method 1.
If it is a web project, we recommend that you use method 2 first. If not, you can use method 3.
Note: In method 2, when you add an external jar package to the project folder (for example, when writing a web project, we may copy the jar package to the WEB-INF/lib folder ), the newly added jar package is not displayed in eclipse. In this case, you can refresh the project (right-click your project directory and click Refresh.