线程“main”中的异常 java.lang.NullPointerException (eclipse)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20751119/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 04:05:07  来源:igfitidea点击:

Exception in thread "main" java.lang.NullPointerException (eclipse)

javaeclipseexceptionnullpointerexceptionmain

提问by motahareh ar

my code is :

我的代码是:

import ir.sbu.nlp.wordnet.data.model.FNSense;
import ir.sbu.nlp.wordnet.data.model.FNSynset;
import ir.sbu.nlp.wordnet.data.model.FNSynsetsRelation;
import ir.sbu.nlp.wordnet.service.FNSynsetService;
import java.util.Vector;
public class sample2 {
public static void main(String[] args) {
        FNSynsetService service=new FNSynsetService();
        service.findAll();
       }
}

and when I run it display this error

当我运行它时显示此错误

   Data Load Started...
   Exception in thread "main" java.lang.NullPointerException
   at ir.sbu.nlp.wordnet.data.dao.FNWordDao.getTextNode(FNWordDao.java:513)
   at ir.sbu.nlp.wordnet.data.dao.FNWordDao.loadWords(FNWordDao.java:438)
   at ir.sbu.nlp.wordnet.data.dao.FNWordDao.<init>(FNWordDao.java:76)
   at ir.sbu.nlp.wordnet.data.dao.FNDaoManager.<init>(FNDaoManager.java:25)
   at ir.sbu.nlp.wordnet.data.dao.FNDaoManager.getInstance(FNDaoManager.java:40)
   at ir.sbu.nlp.wordnet.service.FNSynsetService.<init>(FNSynsetService.java:51)
   at sample2.main(sample2.java:12)
   Data Load Started...
   Exception in thread "main" java.lang.NullPointerException
   at ir.sbu.nlp.wordnet.data.dao.FNWordDao.getTextNode(FNWordDao.java:513)
   at ir.sbu.nlp.wordnet.data.dao.FNWordDao.loadWords(FNWordDao.java:438)
   at ir.sbu.nlp.wordnet.data.dao.FNWordDao.<init>(FNWordDao.java:76)
   at ir.sbu.nlp.wordnet.data.dao.FNDaoManager.<init>(FNDaoManager.java:25)
   at ir.sbu.nlp.wordnet.data.dao.FNDaoManager.getInstance(FNDaoManager.java:40)
   at ir.sbu.nlp.wordnet.service.FNSynsetService.<init>(FNSynsetService.java:51)
   at sample2.main(sample2.java:12)

Can every one help me? I copy every file needed for installation

每个人都可以帮助我吗?我复制安装所需的每个文件

采纳答案by Vivek Vermani

Seems like you need to set some object before calling service.findAll();

似乎您需要在调用 service.findAll(); 之前设置一些对象;

While this method is executing it might be trying to access some object which is turning out to be null. Debug and find out the exact line which is throwing NPE.

在执行此方法时,它可能试图访问某个结果为 null 的对象。调试并找出抛出 NPE 的确切线路。