lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jon Schuster" <>
Subject RE: Index files in jar
Date Mon, 29 Aug 2005 17:07:47 GMT
Hi Tom,

You could distribute your index files in a plain old directory outside
of a jar file and install them with your application, then use
FSDirectory to read from the installed location.

But I can think of at least two ways to get the index files packaged
into the application jar. One would be to write your own subclass of
Directory (and perhaps IndexReader) that knows how to read entries
directly from the jar file using JarInputStream. The other would be to
use a RAMDirectory and populate the directory with the index files,
perhaps reading the files using Class.getResourceAsStream or by creating
a JarInputStream from an URL to the application jar.

You can easily get an InputStream to your own application jar like this:

	CodeSource cs = theClass.getProtectionDomain().getCodeSource();
	URL providerURL = cs.getLocation();
	InputStream is = providerURL.openStream();

Have fun,

-----Original Message-----
From: Thomas Lepkowski [] 
Sent: Monday, August 29, 2005 8:43 AM
Subject: Index files in jar


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
in a jar file. I tried this, but the search choked when I told
the index path inside the jar file ( and placed the jar file path in the


Any ideas on wrapping my index files inside a jar file?

Thanks in advance for any help.


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

View raw message