Wget not working to load jar file from maven repo

I am trying to download a single jar file from the maven repository from the url below.

http://repo1.maven.org/maven2/com/google/guava/guava-testlib/10.0/guava-testlib-10.0.jar

  • Downloading in the browser works fine, and I get the file as expected.

  • 'wget' is loading something, but the file I get is not valid. Running "jar -tf" in the downloaded file gives "ZipException: error opening zip file."

  • Downloading the file programmatically from Java (“InputStream” from the URL written to “FileOutputStream”) downloads something and creates the file. Opening it with WinZip / 7-Zip, it contains one file called "guava-testlib-10.0", which looks like the jar archive that I expected to receive.

  • wget another jar works as expected, at least sometimes (with user agent string -U )

Is this some tricky interaction between wget / maven or Java / maven? Is this the wrong jar file that my browser correctly understands and downloads? Both of them seem implausible to me.

+8
java jar maven guava wget
source share
1 answer

wget is usually blocked from the central maven repository because some people do not play well and try to work too much. Try installing the user agent:

 wget -U "Any User Agent" http://repo1.maven.org/maven2/com/google/guava/guava-testlib/10.0/guava-testlib-10.0.jar 
+10
source share

All Articles