How To Download Jars From Maven Repository

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 another method that does not use maven to download jar files but download the jar files from the maven repository directly. It will also tell you how to add the download jar files in your eclipse java project java build path.

1. Download Jar From Maven Central Repository Steps.

  1. Open a web browser and browse to go to the maven central repository website.
  2. Input the jars maven groups, artifacts, or categories name in the search box on the page top area and click the Search button. Then it will list all the related library links.
  3. For example, if we want to download the google Gson library jar files in the maven central repository, we type Gson and click Search.
  4. Click the Gson link to go to the library detail page.
  5. Click the version number that you need, in this example, we click version link 2.8.5 to go to that version detail page.
  6. In the Gson version detail page, on the Files row, you can see a link whose link text is something like jar (235 KB ). This is just the Gson jar file download link.
  7. Click the above link to download the Gson version 2.8.5 jar file.

2. Download Jar From

  1. There is another maven repository that you can download jar files from.
  2. Open a web browser and browse the URL or
  3. Input the jar library group name or artifact name in the search box, it will list all matched jar libraries.
  4. If you know the jar library group name, artifact name, and version, you can input something like g:com.dolphindb AND a:jdbc AND v:1.10.2 in the search box, this can make the search more accurate.
  5. Now it will list the matched maven jar library on the page, click the Download link at the end of the row, then you can select download jar, javadoc.jar, pom, or sources.jar file.
  6. But if you browse into some artifact detail webpage ( for example ), when you click the Download link at the top right corner of the page, it will only list one item pom.
  7. In such a case, you can search the artifact name in the search box, and click each listed artifact’s Download link, and you can find some links that can download the jar item and some links that can only download the pom.

3. How To Download Maven Artifact From Remote To Local Repository In Command-Line.

3.1 Question.

  1. I write a java library jar and use maven to distribute it to users.
  2. But some of my java library users do not use maven to build their java projects, so they do not use pom.xml in their projects.
  3. So I want to find a command line that can help them to download the java library artifacts to the folder ~/.m2/repository on their local computer so that they can use it locally.
  4. And that is a good way for them to use maven later if they want.
  5. So I googled and get the command line like below. The below command line will use the maven install plugin to install the jar file I think.
    mvn install:install-file -Durl= -Dfile=test.jar -DpomFile=test.pom -DgroupId=test -DartifactId=test -Dversion=1-SNAPSHOT -Dpackaging=jar
  6. But when I run the above command line, I find it does not download the java library jar file from the remote repository to the local repository folder, instead it just copies the files that are built locally to the folder ~/.m2/repository on the local computer.
  7. How to download the java library artifact from the remote repository to the local repository in the command line? Thanks a lot.

3.2 Answer1.

  1. You can use the maven dependency plugin’s dependency:get goal to implement your task.
  2. But you need to make sure the dependency plugin version is the correct version.
  3. And you should provide the fully qualified name (test:test:1.2-SNAPSHOT) of your java artifact when you use the above dependency plugin.
  4. Below is an example of using the maven dependency plugin to download the artifact to your local repository.
    mvn org.apache.maven.plugins:maven-dependency-plugin:2.1:get \
    -DrepoUrl= \
  5. When you run the above command, it will download the remote artifact to the local maven repository ~/.m2/repository.
  6. If you want to download the remote java artifact to another local directory, you can specify it using the argument -Ddest=/user/local/test.jar. Then it will download and save the remote java artifact to the /user/local/test.jar file.
    mvn org.apache.maven.plugins:maven-dependency-plugin:2.1:get \ 
          -DrepoUrl= \ 
          -Dartifact=test:test:1.2-SNAPSHOT \

4. Add Download Jars Into Java Project.

  1. After downloading jar files from the maven central repository, before you can use them, you need to add them to your java project (2022/05/23).
  2. Below are the steps to add the jar to your java project using eclipse.
  3. Right-click the java project name in eclipse, and click the Properties menu item in the popup menu list.
  4. Click Java Build Path menu item in the left panel of the popup window, click the Libraries tab in the right panel, and click Add External JARs button below the Libraries tab.
  5. Browse to the folder where the downloaded jar file is saved and click the Open or Save button to add it to the java build path.
  6. Then click Apply and Close button to add the jars to the java project.
  7. Now you can use the Java classes contained in the jar files in your java source code.

3 thoughts on “How To Download Jars From Maven Repository”

  1. I have a java application, and I want to deploy it in a script file. In the script file, it should first download the java app jar file to a local directory from a central repository, and them run the jar file in java command line.

    I do not know how to download my java app jar file to a specified folder in the script, my question is not downloading the jar file to maven local repository, but download it to any local folder.

    Can anyone give me some help? Thanks a lot.

  2. Vidyasagar Mundroy

    It took a while as I was looking for a link name “Download” but did not find one. Then I referred to your article as the download link is given by field “Files”! Thanks a lot.

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.