【问题标题】:How to include multiple class files and .Jar files in class path which exist in sub folders in linux?如何在 linux 子文件夹中的类路径中包含多个类文件和 .Jar 文件?
【发布时间】:2013-06-21 10:13:43
【问题描述】:

如何在类路径中包含多个类文件和 .Jar 文件,我在 linux 上.. 并且想将下载的 lucene 包与我的代码集成,所有库和类文件都在 lucene 目录中。 (它们是该文件夹内的多个子目录)?

HelloLucene.java:1: error: package org.apache.lucene.analysis.standard does not exist
import org.apache.lucene.analysis.standard.StandardAnalyzer;
                                          ^
HelloLucene.java:10: error: package org.apache.lucene.queryparser.classic does not exist
import org.apache.lucene.queryparser.classic.ParseException;
                                            ^
HelloLucene.java:11: error: package org.apache.lucene.queryparser.classic does not exist
import org.apache.lucene.queryparser.classic.QueryParser;
                                            ^
HelloLucene.java:23: error: cannot find symbol
  public static void main(String[] args) throws IOException, ParseException {
                                                             ^
  symbol:   class ParseException
  location: class HelloLucene
    HelloLucene.java:26: error: cannot find symbol
    StandardAnalyzer analyzer = new StandardAnalyzer(Version.LUCENE_40);
    ^
  symbol:   class StandardAnalyzer
  location: class HelloLucene
HelloLucene.java:26: error: cannot find symbol
    StandardAnalyzer analyzer = new StandardAnalyzer(Version.LUCENE_40);
                                    ^
  symbol:   class StandardAnalyzer
  location: class HelloLucene
HelloLucene.java:45: error: cannot find symbol
    Query q = new QueryParser(Version.LUCENE_40, "title", analyzer).parse(querystr);
                  ^
  symbol:   class QueryParser
  location: class HelloLucene
Note: HelloLucene.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
7 errors

【问题讨论】:

    标签: java apache lucene


    【解决方案1】:

    使用以下命令:

    export CLASSPATH="$CLASSPATH:xyz.jar**:**path_to_abc.jar.jar"
    

    您基本上必须将所有您想要的新条目附加到类路径中。为此,只需在 linux 中使用 ':' 和 ';'在窗口中。

    【讨论】:

    • 但是它是如何递归包含所有jar文件和类文件的呢?
    • export CLASSPATH="$CLASSPATH:directory" 目录:递归提取jar的目录(包含所有jar文件列表的目录。
    • 我如何查找是否包含所有文件?我在终端中执行了命令并运行了我的 prgm ,它仍然给了我一个 eroor
    • 你能编辑帖子并告诉我你得到的错误是什么吗?
    • 好吧,所有的导入文件如“import org.apache.lucene.document.Field;”不加载..我的意思是包,我需要root才能使用导出命令吗?
    【解决方案2】:

    您可以将路径添加到 jar 所在的文件夹中,然后递归地选择内部 jar。

    【讨论】:

      猜你喜欢
      • 2012-02-15
      • 2023-03-18
      • 2023-03-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-04-29
      相关资源
      最近更新 更多