NoClassDefFoundError: opennlp/tools/chunker/ChunkerModel

偶尔善良 提交于 2020-01-17 05:19:49

问题


Got this error while trying opennlp chunking:

NoClassDefFoundError: opennlp/tools/chunker/ChunkerModel

Here is the basic code:

import java.io.*;
import opennlp.tools.chunker.*;

public class test{
        public static void main(String[] args) throws IOException{  
                ChunkerModel model = null;
                InputStream modelIn = new FileInputStream("en-parser-chunking.bin");
                model = new ChunkerModel(modelIn);
        }
}

回答1:


I don't see any NLP-specific reasons here, so just check tutorials about NoClassDefFoundError, for example:

Verify that all required Java classes are included in the application’s classpath. The most common mistake is not to include all the necessary classes, before starting to execute a Java application that has dependencies on some external libraries.

The classpath of the application is correct, but the Classpath environment variable is overridden before the application’s execution."

or related question.

In particular, check that you have appropriate (and only one) version of opennlp jar in your classpath.

*it is not a good style to import all content of the package (by using wildcard) - instead, use IDE's support: e.g. ctrl+shift+o in Eclipse (ctrl+alt+o in IDEA) automatically resolves all needed imports.



来源:https://stackoverflow.com/questions/29311650/noclassdeffounderror-opennlp-tools-chunker-chunkermodel

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!