lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jon Schuster" <j...@attachmatewrq.com>
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,
--Jon


-----Original Message-----
From: Thomas Lepkowski [mailto:thomlep@gmail.com] 
Sent: Monday, August 29, 2005 8:43 AM
To: java-user@lucene.apache.org
Subject: Index files in jar


Hello,

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

CLASSPATH ).

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

Thanks in advance for any help.

-Tom

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message