tags:

views:

1096

answers:

5

I've inherited an app that uses Spring. The original developers are not available. The Spring jar file is just "spring.jar", so there's no version# in the filename to help me. I'd like to download the Spring source corresponding to the jar file. The MANIFEST.MF file has "Spring-Version: 1.2" however that's not precise enough. I've looked at version 1.2.1 and 1.2.9 and it doesn't match up quite right. The key thing is that org.springframework.web.servlet.view.AbstractCachingViewResolver has a prepareView method which is called from resolveViewName and it does not seem to be in 1.2.1 or 1.2.9.

Is there any easy way to track down the right version?

+1  A: 

How about checksumming the JAR file and comparing it to the spring.jar files in the distributions from SpringSource? Might take an hour or so to do the downloads, but it should be definitive.

mtnygard
+8  A: 

This will do it:

import org.springframework.core.SpringVersion;

public class VersionChecker
{
    public static void main(String [] args)
    {
        SpringVersion version = new SpringVersion();

        System.out.println("version: " + version.getVersion());
    }
}

Compile and run this with spring.jar in your CLASSPATH and it'll display the version for you. See the javadocs as well.

duffymo
It came back as "1.2" :(
Gary Kephart
I tested this against Spring JARs I have on my desktop. It was able to distinguish between 2.5.2, 2.5.6, and 3.0.0.M2, so I say the code is correct. Besides, it's a class from Spring - are you gonna doubt them? Looks like you have 1.2.
duffymo
Just checked it against another spring.jar that's some earlier work. I had no idea of the version, but the code came back with 1.2.6. I'm not sure why you only get 1.2.
duffymo
Except that there's no download for just "1.2". There's 1.2.0, 1.2.0.RC1 and 1.2.0.RC2. I took the time to download all of them, and it looks like I have either RC1 or RC2, both of which have the `prepareView` method. Just 1.2.0 does not have it though.
Gary Kephart
Yeah, that 3.0.0.M2 JAR that I had included even that last bit. I'm surprised that it didn't show up for you.
duffymo
But, thanks for getting me close with the SpringVersion.getVersion method.
Gary Kephart
Thank you - I didn't know it was there until I looked for it. I learned something, too.
duffymo
Perhaps someone compiled the JAR themselves from source?
matt b
But if that source included the SpringVersion class from Rod Johnson's guys, I'd imagine that it would still report the version number faithfully. It's odd that it does not act like the 1.x, 2.x, and 3.x examples that I have.
duffymo
A: 

According to mvnrepository.com 1.2.9 weights 2.2MB and 1.2.1 weights 2.0MB, that page also has a link for downloading both. I think the weight difference is enough for comparing the files. If you can't see the difference just checksum. If you can't see a relation neither with 1.2.1 nor 1.2.9 you can use the page to download any other version quickly (I use it often)

NOTE: If your JAR is below 2.0MB then I'm afraid duffymo has reason and your JAR is 1.2

victor hugo
I don't see how size is relevant for determining version. The 1.2.6 version I have is 1.8MB, but they don't choose the version number based on size. Did I miss something about your suggestion?
duffymo
A: 

You can try looking inside the jar's MANIFEST.MF in the META-INF directory - it should indicate what version yo're working with.

Michael Wiles
+1  A: 

The really easy way is to get the MD5 sum of the archive and google it. Many sites that store .jar archives also index the MD5 sums which Google then finds easily. This works really well for pretty much any Java components.

$ md5sum spring-2.5.5.jar
82a2134b227f717066da4f4b059925d3

http://www.google.com/search?q=82a2134b227f717066da4f4b059925d3

vehnae