Ошибка простой пример lucene 4.0 с исходным кодом (не jar lib)

Изменить: Я нашел решение: отредактируйте файл core.jar, удалите все пакеты, кроме пакета кодеков, и добавьте в путь сборки, пакет кодеков должен быть в jar, может 'я не могу быть исходным кодомПонимаю, что это очень простой код для Lucene, он работает с ядром Lucene, но вызывает ошибку, когда я использую исходный код Lucene.

public static void main(String[] args) throws IOException, ParseException {
    Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_CURRENT);

    // Store the index in memory:
    Directory directory = new RAMDirectory();
    // To store an index on disk, use this instead:
    // Directory directory = FSDirectory.open("/tmp/testindex");
    IndexWriterConfig config = new IndexWriterConfig(
            Version.LUCENE_CURRENT, analyzer);
    IndexWriter iwriter = new IndexWriter(directory, config);
    Document doc = new Document();
    String text = "This is the text to be indexed.";
    doc.add(new Field("fieldname", text, TextField.TYPE_STORED));
    iwriter.addDocument(doc);
    iwriter.close();

    // Now search the index:
    DirectoryReader ireader = DirectoryReader.open(directory);
    IndexSearcher isearcher = new IndexSearcher(ireader);
    // Parse a simple query that searches for "text":
    QueryParser parser = new QueryParser(Version.LUCENE_CURRENT,
            "fieldname", analyzer);
    Query query = parser.parse("text");
    ScoreDoc[] hits = isearcher.search(query, null, 1000).scoreDocs;
    // Iterate through the results:
    for (int i = 0; i < hits.length; i++) {
        Document hitDoc = isearcher.doc(hits[i].doc);
                System.out.println(hitDoc.get("fieldname"));
    }
    ireader.close();
    directory.close();
}

Ошибка:

 Exception in thread "main" java.lang.ExceptionInInitializerError
        at org.apache.lucene.index.LiveIndexWriterConfig.(LiveIndexWriterConfig.java:118)
        at org.apache.lucene.index.IndexWriterConfig.(IndexWriterConfig.java:145)
        at Test.main(Test.java:34)
    Caused by: java.lang.IllegalArgumentException: A SPI class of type org.apache.lucene.codecs.Codec with name 'Lucene40' does not exist. You need to add the corresponding JAR file supporting this SPI to your classpath.The current classpath supports the following names: []
        at org.apache.lucene.util.NamedSPILoader.lookup(NamedSPILoader.java:104)
        at org.apache.lucene.codecs.Codec.forName(Codec.java:95)
        at org.apache.lucene.codecs.Codec.(Codec.java:122)
        ... 3 more

Ответы на вопрос(1)

Ваш ответ на вопрос