【发布时间】:2014-11-25 16:47:44
【问题描述】:
我在我的项目中使用 afterburner.fx DI。一切正常,除非我尝试将文件加载到从资源文件夹注入的对象中。
我尝试输入getClass().getResource()、Class_name.class.getResource ...但似乎不起作用。
例如,我尝试加载图像以用作应用程序的图标,因此我尝试使用(其他不起作用的方法):
getIcons().add(new Image(Thread.currentThread().getContextClassLoader().getResourceAsStream("/img/logo.png")));
所有方式都返回相同的错误:
java.lang.NullPointerException: Input stream must not be null
【问题讨论】:
标签: java dependency-injection nullpointerexception javafx embedded-resource