If you use maven in your java project, you should use pom.xml to add dependencies that your java project required. But sometimes you may need to add the third party library jar files directly in your java project instead of using maven pom.xml. This article will tell you how to do it.
1. Download Jars From Maven Central Repository Steps.
- Open a web browser and browse http://mvnrepository.com/ to goto maven central repository website.
- Input the jars maven groups, artifacts or categories name in the search box and click search button. Then it will list all the related library link.
- For example, we want to download the google GSON library jars in maven central repository, we just type GSON and click Search.
- Click the Gson link to go to the library detail page.
- Click the version number that you need, in this example we click version link 2.8.5 to go to that version detail page.
- In the GSON version detail page, after Files column you can see a link which link text is jar (235 K ). This is just the Gson jar file link.
- Click above link to download the gson version 2.8.5 jar file.
2. Add Download Jars Into Java Project.
After download jar files from maven central repository, before you can use it, you need to add it into your java project. Below is the steps to add the jar in your java project using eclipse.
- Right click the java project name in eclipse, and click Properties menu item in the popup menu list.
- Click Java Build Path menu item in left panel of the popup window, click Libraries tab in right panel, and click Add External JARs button.
- Browse to the folder where the downloaded jar file is saved and click open or save button to add it to the java build path. Then click Apply and Close button to add the jar in java project. Now you can use the jars contained java classes in your java code.