我从https://stanfordnlp.github.io/CoreNLP/下载了stanford corenlp zip文件,然后将其解压缩并插入其中 . 现在我尝试运行以下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 . *;
公共课SentimentAnalysis {
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
1 回答
使用以下步骤验证jar
从http://jd.benow.ca/下载Java decomiler
通过下载的反编译器打开jar
验证是否存在所需的StanfordCoreNLP类
如果有课程,请按照以下文章发表how to run Java program including jar