On Fri, 2005-08-26 at 16:31 -0400, Thomas Lepkowski wrote: > I have a set of index files that I'd like to distribute with my Java > application. The only way this seems practical is to place the index files > in a jar file. I tries this, but the search choked when I told IndexSearcher > the index path inside the jar file ( and placed the jar file in the > CLASSPATH. > > Anybody out there successfully put their index files in a jar file? > > Thanks in advance for any advise.
I haven't but I have an idea of how you would. What path did you give IndexSearcher? Did you use the IndexSearcher(String) constructor? I don't think there's any chance you could load an index from a JAR file out of the box. First a JAR file is zipped, secondly you'll look it up from the classpath rather than giving a file system path. I would guess you need to extend: org.apache.lucene.store.Directory and create a JARDirectory class, which can find the appropriate bits within the JAR for Lucene. First get the JAR file: ClassLoader.getSystemResourceAsStream(jarFilename) then use the java.util.jar.JarInputStream class to read it. One potential problem might be random access, since I think streams are sequentially accessed. If the index isn't too big you could have your JARDirectory class just wrap a RAMDirectory and just load the contents of the JAR into memory. -- Miles Barr <[EMAIL PROTECTED]> Runtime Collective Ltd. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]