1

I am using Lucene and trying to set the classpath for the four jar files as mentioned in the Lucene 5.0.0 demo API "You need four JARs: the Lucene JAR, the queryparser JAR, the common analysis JAR, and the Lucene demo JAR.

Put all four of these files in your Java CLASSPATH.

I am trying to set classpath variable by entering the following variable value in classpath environment variable "F:\Academic\KAU_ResearchGroups\PlagiarismDetection\Lucene\lucene-5.0.0\core; F:\Academic\KAU_ResearchGroups\PlagiarismDetection\Lucene\lucene-5.0.0\queryparser; F:\Academic\KAU_ResearchGroups\PlagiarismDetection\Lucene\lucene-5.0.0\analysis\common; F:\Academic\KAU_ResearchGroups\PlagiarismDetection\Lucene\lucene-5.0.0\demo;

but whenever I run the following command: java org.apache.lucene.demo.IndexFiles -docs {path-to-lucene}/src

I get the error message "Error: Could not find or load main class org.apache.lucene.IndexFiles".

How can I sort out this problem

Qazi
  • 13,791
  • 3
  • 15
  • 19

2 Answers2

3

Looks like what you've added to the classpath isn't correct. Either add the jars directly, as in the instructions of the IndexFiles demo:

F:\Academic\KAU_ResearchGroups\PlagiarismDetection\Lucene\lucene-5.0.0\core\lucene-core-5.0.0.jar; ...

Or add the whole directory with a wildcard (see Setting multiple jars in java classpath):

F:\Academic\KAU_ResearchGroups\PlagiarismDetection\Lucene\lucene-5.0.0\core\*; ...

Community
  • 1
  • 1
femtoRgon
  • 32,893
  • 7
  • 60
  • 87
-1

You should never trust them, upload previous versions, When I worked with Lucene I always had this type of errors so I uploaded all lucen versions from the first one till the last(lucen1.9, lucene 2......, Lucene 3.3, lucene 4) and I added them as jars and till now I don't know which one had resolved the problem ;) don't worry about the difference between the declaration of functions when you use them, you can use the version like this Query q = new QueryParser(Version.LUCENE_40, "title", analyzer).parse(querystr);

good luck

  • Having mismatched lucene versions in your classpath is a likely *cause* of errors. The fact that you resolved an issue by installing a bunch of old versions of lucene is positively puzzling. Passing an older version into a method call using something like `Version.LUCENE_40` instructs it to use compatibility logic built into your *current* version of lucene, not to load up old jars on your classpath. Doesn't work like that. – femtoRgon Apr 06 '15 at 06:14