lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erik Hatcher <>
Subject Re: two versioning problems with Lucene
Date Tue, 07 Dec 2004 09:30:54 GMT

On Dec 6, 2004, at 10:39 PM, Jeff Breidenbach wrote:
> The first is that there is no way to tell from "inside" Java which
> version of Lucene you have.  There should be some top level class,
> perhaps org.apache.lucene.VERSION, which contains at least three
> variables, "majorVersion", "minorVersion", and "microVersion", so that
> a user program can check which version of the system they are using.

This is not quite true.  The full version number is in the Lucene JAR 
manifest, which you can obtain like this:

public class PackageTester {
   public static void main(String[] args) throws IOException {
     JarFile jarFile = new JarFile(args[0]);
     Manifest manifest = jarFile.getManifest();

     Map entries = manifest.getEntries();
     Attributes attributes = (Attributes) 


Where args[0] is the path to the Lucene JAR file.  I'm not familiar 
enough with the manifest API, but it should be possible to get to this 
version number without having to know the path to the JAR file, as long 
as its in the classpath.  I experimented briefly with the Package API, 
but was not able to get it to work using 
Package.getPackage("org.apache.lucene"), as there are no actual classes 
in that package.

We could easily store the version number in a Java static variable 
somewhere, but let's first explore whether the manifest information is 
sufficient.  I'd prefer to only store the version information in one 
place, and the manifest seems the appropriate spot.  We could also 
break this down into parts for major, minor, etc parts though it is 
parsable enough as it is, I think.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message