Main Tutorials

How to download from Maven remote repository?

According to Apache Maven :

Downloading in Maven is triggered by a project declaring a dependency that is not present in the local repository (or for a SNAPSHOT, when the remote repository contains one that is newer). By default, Maven will download from the central repository.

In Maven, when you’re declared library does not exist either inlocal repository nor Maven center repository, the process will stop and output error messages to your Maven console.

1. Example

The org.jvnet.localizer is only available at Java.net repository.

pom.xml

    <dependency>
        <groupId>org.jvnet.localizer</groupId>
        <artifactId>localizer</artifactId>
        <version>1.8</version>
    </dependency>

When you build this Maven project, it will fail and output dependency not found error message.

Updated 12/12/2012
The org.jvnet.localizer is now available in Maven center repository.

2. Declare Java.net repository

To tell Maven to get the dependency from Java.net, you need to declared a remote repository in your pom.xml file like this :

pom.xml

    <repositories>
	<repository>
	    <id>java.net</id>
	    <url>https://maven.java.net/content/repositories/public/</url>
	</repository>
    </repositories>

Now, Maven’s dependency library look-up sequences is changed to :

  1. Search in Maven local repository, if not found, go step 2, else exit.
  2. Search in Maven central repository, if not found, go step 3, else exit.
  3. Search in java.net Maven remote repository, if not found, prompt error message, else exit.

References

  1. How To Add Remote Repository In Maven

About Author

author image
Founder of Mkyong.com, love Java and open source stuff. Follow him on Twitter. If you like my tutorials, consider make a donation to these charities.

Comments

Subscribe
Notify of
10 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments
Jason Rembert
8 years ago

You can also download the jar files with dependencies from this site: http://jar-download.com/

Quoc Anh
9 years ago

i’m start learning about maven, and your blog is very helpful. thank you verymuch.

gilbert
11 years ago

Your blog is very helpful for beginners in maven. I wanted to know, how do I find out the of a repository when I already have the dependency information. for example, the dependency information is:

org.eclipse.equinox
org.eclipse.osgi
3.4.2

how do I find out the repository information from the element

Amit
11 years ago

In the post you have mentioned “…a dependency that is not present in the local repository (or for a SNAPSHOT, when the remote repository contains one that is newer)… “. I don’t know what you mean by the term “SNAPSHOT”. Can you please explain it a bit or direct me to the link where it is explained.

Thanks.

sniper
11 years ago
Reply to  Amit

?????????snapshot??????????

RoarLion
9 years ago
Reply to  sniper

A snapshot version in Maven is one that has not been released.

The idea is that before a 1.0 release (or any other release) is done, there exists a 1.0-SNAPSHOT. That version is what might become 1.0. It’s basically “1.0 under development”. This might be close to a real 1.0 release, or pretty far (right after the 0.9 release, for example).

The difference between a “real” version and a snapshot version is that snapshots might get updates. That means that downloading 1.0-SNAPSHOT today might give a different file than downloading it yesterday or tomorrow.

Usually, snapshot dependencies should only exist during development and no released version (i.e. no non-snapshot) should have a dependency on a snapshot version.

Siddhanta Kumar Pattnaik
12 years ago

Greate mkyong…
Very Very thanks to u for ur Tutorial……………

venkat
12 years ago

hello mkyong,

I learnt a few java technologies before. now am learning new technologies from yours.
since am a novice to real tome development, am just curious to know how the project phases go on from specification to testing.
could you post an article or ideas accordingly. Thank you

RoarLion
9 years ago
Reply to  venkat

it depends on the process.
usual water fall way .

requirement Specification -> Architechture-> ->functional specifications -> design -> implmentation (development ) -> unit testing -> QA testing -> system integration testing -> UAT deployment -> UAT testing (user acceptance testing ) -> production deployment -> post production support

correct me If I am wrong