如何为lucene jar文件设置类路径

How to set classpath for lucene jar files

我正在使用 Lucene 并尝试为 Lucene 5.0.0 演示中提到的四个 jar 文件设置类路径 API “您需要四个 JAR:Lucene JAR、queryparser JAR、通用分析 JAR 和 Lucene 演示 JAR。

将所有这四个文件放入您的 Java CLASSPATH。

我试图通过在类路径环境变量中输入以下变量值来设置类路径变量 "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;

但每当我 运行 执行以下命令时: java org.apache.lucene.demo.IndexFiles -docs {path-to-lucene}/src

我收到错误消息 "Error: Could not find or load main class org.apache.lucene.IndexFiles"。

我该如何解决这个问题

你永远不应该相信他们,上传以前的版本,当我使用 Lucene 时,我总是遇到这种类型的错误所以我上传了从第一个到最后一个的所有 lucen 版本(lucen1.9,lucene 2 ... ...,Lucene 3.3,lucene 4),我将它们添加为罐子,直到现在我都不知道哪个解决了问题;) 使用时不用担心函数声明的不同,可以这样使用版本 查询 q = new QueryParser(Version.LUCENE_40, "title", analyzer).parse(querystr);

祝你好运

您添加到类路径中的内容似乎不正确。直接添加罐子,如 instructions of the IndexFiles demo:

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

或者用通配符添加整个目录(参见Setting multiple jars in java classpath):

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