views:

291

answers:

4

What is the easiest way to find the Struts library version? I'm adding Struts libraries to an generic eclipse project, and need to be able to differentiate between versions.

(Other libraries like Spring have a getVersion() call)

I can always read the jar manifest, but I'm looking for an easier way.

A: 

If Struts does not itself indicate its version in the classes (and I could find one with a quick look), you could add a small static class to the jar that gives its version. This requires a bit of work in the beginning but is then as easy as you want.

I'm not certain if that would be easier than writing a function to read the manifest (assuming the function only has to be written once).

Kathy Van Stone
A: 

Maybe you should consider using MAVEN. When MAVEN gets the libraries you need (as you express them in the pom.xml file of your project), the jar names include the version number.

See maven.apache.org/

Normally a SHA print of each jar is also available in the MAVEN repository, so you can check with pretty assurance that a given jar is actually the expected version.

Example : http://mirrors.ibiblio.org/pub/mirrors/maven2/struts/struts/1.2.9/

maven-metadata.xml 22-Mar-2006 20:31 111
[TXT] maven-metadata.xml.md5 04-Jan-2007 14:22 75
[TXT] maven-metadata.xml.sha1 09-Jul-2006 09:41 130
[ ] struts-1.2.9-sources.jar 13-Apr-2006 02:39 904K
[ ] struts-1.2.9-sources.jar.md5 13-Apr-2006 01:22 36
[ ] struts-1.2.9-sources.jar.sha1 13-Apr-2006 01:22 44
[ ] struts-1.2.9.jar 22-Mar-2006 20:31 537K
[ ] struts-1.2.9.jar.md5 22-Mar-2006 20:31 32
[ ] struts-1.2.9.jar.sha1 22-Mar-2006 20:31 40
[TXT] struts-1.2.9.pom 22-Mar-2006 20:31 9.2K
[ ] struts-1.2.9.pom.md5 22-Mar-2006 20:31 32
[ ] struts-1.2.9.pom.sha1 22-Mar-2006 20:31 40

zim2001
A: 

Generate a md5 checksum of the jar and then do a google search on the checksum. If you get any hits it will probably be for the jar in a Maven repository (and the url will contain the version number).

This works with most but not all jars.

Jon Strayer
A: 

ssssaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

sss