ordinary
ordinary

Reputation: 6133

Why can't I compile the lucene demo sourcecode with javac?

I downloaded the source code from here --> http://lucene.apache.org/core/4_5_1/demo/overview-summary.html

Now I've gone to the source file, IndexFiles.java, and I type javac IndexFiles but I get a bunch of symbol not found errors. Why? I changed my classpath and added all the *.jar files in the directory. What could I be missing here? I am able to use the binaries and run the demo, but I want to mess with the demo and change some of its behavior, so I wanted to compile from source.

When I type javac IndexFiles.java I get a bunch of errors in this vein:

package org.apache.lucene.analysis does not exist
import org.apache.lucene.analysis.Analyzer;
                                 ^
IndexFiles.java:20: error: package org.apache.lucene.analysis.standard does not exist
import org.apache.lucene.analysis.standard.StandardAnalyzer;
                                          ^
IndexFiles.java:21: error: package org.apache.lucene.document does not exist
import org.apache.lucene.document.Document;
                                 ^
IndexFiles.java:22: error: package org.apache.lucene.document does not exist
import org.apache.lucene.document.Field;
                                 ^
IndexFiles.java:23: error: package org.apache.lucene.document does not exist
import org.apache.lucene.document.LongField;
                                 ^
IndexFiles.java:24: error: package org.apache.lucene.document does not exist
import org.apache.lucene.document.StringField;
                                 ^
IndexFiles.java:25: error: package org.apache.lucene.document does not exist
import org.apache.lucene.document.TextField;
                                 ^
IndexFiles.java:26: error: package org.apache.lucene.index does not exist
import org.apache.lucene.index.IndexWriter;
                              ^
IndexFiles.java:27: error: package org.apache.lucene.index.IndexWriterConfig does not exist
import org.apache.lucene.index.IndexWriterConfig.OpenMode;
                                                ^
IndexFiles.java:28: error: package org.apache.lucene.index does not exist
import org.apache.lucene.index.IndexWriterConfig;
                              ^
IndexFiles.java:29: error: package org.apache.lucene.index does not exist
import org.apache.lucene.index.Term;
                              ^

Upvotes: 3

Views: 3978

Answers (2)

Mohasin Ali
Mohasin Ali

Reputation: 4015

I too got annoyed with this problem, I removed unnecessary jar files and add only required jar files in the classpath. Sometimes if you put redundant jar files in the class path will leads to conflicting of the jar files and that will shows the error(like "the type org.apache.lucene.index.DirectoryReader is not visible").
I just added the following jar files in my class path
lucene-core-4.6.1
lucene-analyzers-common-4.6.1
lucene-queryparser-4.6.1

Thank you.

Upvotes: 2

Jeff French
Jeff French

Reputation: 1151

Lucene has multiple JARs. Do you have them in your classpath when you compile the demo class?

Upvotes: 0

Related Questions