【发布时间】:2016-10-02 00:50:20
【问题描述】:
我正在使用 this 示例代码来使用 API。我不想使用 maven,所以我从here 下载了 jar 文件,并将 org 和 lib 中的 Jar 文件包含到构建路径中,然后尝试运行示例代码。我收到了这个错误:
Error:(15, 56) java: cannot find symbol
symbol: class BritishEnglish
location: class draft
Error:(3, 34) java: cannot find symbol
symbol: class BritishEnglish
location: package org.languagetool.language
这是我的代码
import org.languagetool.JLanguageTool;
import org.languagetool.language.BritishEnglish;
import org.languagetool.rules.RuleMatch;
import java.io.*;
import java.util.List;
public class draft {
public static void main(String[] args) throws IOException {
JLanguageTool langTool = new JLanguageTool(new BritishEnglish());
// comment in to use statistical ngram data:
//langTool.activateLanguageModelRules(new File("/data/google-ngram-data"));
List<RuleMatch> matches = langTool.check("A sentence with a error in the Hitchhiker's Guide tot he Galaxy");
for (RuleMatch match : matches) {
System.out.println("Potential error at characters " +
match.getFromPos() + "-" + match.getToPos() + ": " +
match.getMessage());
System.out.println("Suggested correction(s): " +
match.getSuggestedReplacements());
}
}
}
我在网上找到了这个答案,但我不明白。
" BritishEnglish 在 "org" 目录中,而不是在 JAR 中,但您可以像这样放入一个 JAR:“zip -r languages.jar org/”,然后像其他的一样将languages.jar 添加到您的类路径中JAR。"
【问题讨论】:
-
这不是代码问题,而是构建/执行问题。我们需要查看您的 CLASSPATH 以及您如何调用您的草稿类。
-
@jameson 我做了一个编辑,请检查一下,也许你可以帮忙
标签: java cannot-find-symbol languagetool