As discussed in the past... > The problem is that a jar file entry becomes an InputStream, but > InputStream is not random access, and Lucene requires random access. So > you need to extract the index either to disk or RAM in order to get
http://mail-archives.apache.org/mod_mbox/lucene-java-user/200501.mbox/[EMAIL PROTECTED] : Date: Mon, 29 Aug 2005 10:07:47 -0700 : From: Jon Schuster <[EMAIL PROTECTED]> : Reply-To: java-user@lucene.apache.org : To: java-user@lucene.apache.org : Subject: RE: Index files in jar : : 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:[EMAIL PROTECTED] : 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: [EMAIL PROTECTED] : For additional commands, e-mail: [EMAIL PROTECTED] : -Hoss --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]