本文介紹了Stanford CoreNLP中的錯(cuò)誤:java.lang.NoClassDefFoundError的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!
問(wèn)題描述
我下載了Stanford CoreNLP,當(dāng)我運(yùn)行他們的website中給出的代碼時(shí)。我在此行中遇到錯(cuò)誤
StanfordCoreNLP pipeline = new StanfordCoreNLP(props);
錯(cuò)誤如下
Exception in thread "main" java.lang.NoClassDefFoundError: nu/xom/Node at sample1.main(sample1.java:35)
Caused by: java.lang.ClassNotFoundException: nu.xom.Node
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 1 more
我使用的是Eclipse IDE,我應(yīng)該進(jìn)行一些配置嗎?請(qǐng)幫幫我!
推薦答案
我已經(jīng)從您提供的鏈接下載了Stanford-corenlp-2012-01-08.tgz。我使用7-Zip對(duì)其進(jìn)行了解壓縮,找到了另一個(gè)名為Stanford-corenlp-2012-01-08的壓縮文件,并再次使用7-Zip將其解壓縮。具體內(nèi)容如下:
然后我在eclipse中創(chuàng)建了一個(gè)新的Java項(xiàng)目,并在該項(xiàng)目中創(chuàng)建了一個(gè)新的文件夾庫(kù),并將
joda-time.jar
stanford-corenlp-2011-12-27-models.jar
Stanford-corenlp-2012-01-08.jar
xom.jar
罐子到了庫(kù)里。然后將項(xiàng)目的Java構(gòu)建路徑設(shè)置為這些JAR。
接下來(lái),我使用Main方法創(chuàng)建了一個(gè)測(cè)試類。
import java.util.Properties;
import edu.stanford.nlp.pipeline.StanfordCoreNLP;
public class NLP {
/**
* @param args
*/
public static void main(String[] args) {
Properties props = new Properties();
props.put("annotators", "tokenize, ssplit, pos, lemma, ner, parse, dcoref");
StanfordCoreNLP coreNLP = new StanfordCoreNLP(props);
}
}
,最后運(yùn)行應(yīng)用程序。輸出如下所示:
運(yùn)行成功。
希望這將對(duì)您有所幫助。
這篇關(guān)于Stanford CoreNLP中的錯(cuò)誤:java.lang.NoClassDefFoundError的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,