Print

Print


Andrew,




On Jan 11, 2007, at 10:47 AM, Andrew Darby wrote:
> Hello, all.  I'm trying to get started with Lucene for the Code4Lib
> preconference

Excellent!!!

> and was wondering if someone could help.

Of course....

> I'm trying to
> do the first example from the Lucene site
> (http://lucene.apache.org/java/docs/demo.html) on my Windows XP
> machine but when I try to build the test index from the command line
> like so:
>
> C:\lucene-2.0.0>java org.apache.lucene.demo.IndexFiles C:
> \lucene-2.0.0/src
>
> I get the following error:
>
> Exception in thread "main" java.lang.NoClassDefFoundError:
> org/apache/lucene/demo/IndexFiles
>
> My CLASSPATH looks like this:
>
> .;C:\Program Files\QuickTime\QTSystem\QTJava.zip;C:\lucene-2.0.0
> \build\lucene-core-2.0.1-dev.jar;C:\lucene-2.0.0\build\lucene-
> demos-2.0.1-dev.jar;

2.0.1?  Where'd you get that version?

I pulled down the latest stable release, 2.0.0, just now to run
through this myself.

Rather than setting CLASSPATH (an evil thing in the Java world, it
can really bite you at inopportune times), I ran it this way
successfully:

java -cp lucene-core-2.0.0.jar:lucene-demos-2.0.0.jar
org.apache.lucene.demo.IndexFiles src/

> I assume this is a basic error, and something to do with the
> classpath, but as best I can tell everything is correct, the
> IndexFiles.class file is where it should be, etc.  I'm not familiar
> with Java, if you haven't guessed.  Any suggestions?

Sadly the demo that ships with Lucene is pretty weak.  For more
examples, grab the Lucene in Action (LIA) codebase from http://
www.lucenebook.com and fire it up simply by typing "ant" and
following the instructions in the README too.  That code is for
Lucene 1.4.3 - 1.9.x.  Lucene 2.0 removed deprecated methods, and
there are a few tidbits of trivia to adjust LIA code to Lucene 2.0
available here:

        <http://www.nabble.com/Lucene-in-Action-examples-complie-problem-
tf2418478.html#a6743189>

The demo that ships with Lucene is barely usable for anything other
than "yeah, it can search text, but boy is it a hassle to run".  Keep
in mind that Lucene is a low-level library, so for there to be much
of use out of it, you have to build something around it.  The Indexer
and Searcher command-line apps in the LIA code base provide a better
working demo "out of the box", but still quite crude.

        Erik