我从https://stanfordnlp.github.io/CoreNLP/下载了stanford corenlp压缩文件然后解压缩并插入其中。现在我尝试运行以下java文件。 javac -cp "*" SentimentAnalysis.java works
很好,但java SentimentAnalysis
抛出错误,线程“main”中的异常java.lang.NoClassDefFoundError:edu / stanford / nlp / pipeline / StanfordCoreNLP。
import edu.stanford.nlp.pipeline.*;
import java.util。*;
公共课堂情感分析{
public static void main(String[] args) {
// creates a StanfordCoreNLP object, with POS tagging, lemmatization, NER, parsing, and coreference resolution
Properties props = new Properties();
props.setProperty("annotators", "tokenize, ssplit, pos, lemma, ner, parse, dcoref");
StanfordCoreNLP pipeline = new StanfordCoreNLP(props);
// read some text in the text variable
String text = "Hello madam, this is a dam";
// create an empty Annotation just with the given text
Annotation document = new Annotation(text);
// run all Annotators on this text
pipeline.annotate(document);
}
}
错误如下
Exception in thread "main" java.lang.NoClassDefFoundError: edu/stanford/nlp/pipeline/StanfordCoreNLP
at SentimentAnalysis.main(SentimentAnalysis.java:39)
Caused by: java.lang.ClassNotFoundException: edu.stanford.nlp.pipeline.StanfordCoreNLP
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 1 more
答案 0 :(得分:0)
使用以下步骤验证jar
通过下载的反编译器打开jar
验证是否存在所需的StanfordCoreNLP类
如果有课程,请点击此帖how to run Java program including jar