我是搞c#,公司需要修改个java项目,被逼上阵,遇到了个问题,卡了1天 ,查了很多资料,环境变量什么都配置了,小弟无法解决了,只能求助了,问题是获取不到图片路径
icons/man.png
Uncaught error fetching image:
java.lang.NullPointerException
at sun.awt.image.URLImageSource.getConnection(Unknown Source)
at sun.awt.image.URLImageSource.getDecoder(Unknown Source)
at sun.awt.image.InputStreamImageSource.doFetch(Unknown Source)
at sun.awt.image.ImageFetcher.fetchloop(Unknown Source)
at sun.awt.image.ImageFetcher.run(Unknown Source)
代码public ImageIcon getImageIcon(String image) {
System.out.println(path+image);
return new ImageIcon(Toolkit.getDefaultToolkit().getImage(
this.getClass().getClassLoader().getResource("icons/"+image)));
}