2
下面的代碼運行良好的getClass()。getResource()方法返回null部署
ThumbnailLabel lblImg =new ThumbnailLabel(new javax.swing.ImageIcon(
getClass().getResource("/jewelleryerpapplication/GUI/resources/NoPicture.png")));
然後我清理在不同崗位提到這個issue.After構建解決方案當我從dist文件夾中雙擊App.jar時,發生以下異常。
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at javax.swing.ImageIcon.<init>(ImageIcon.java:138)
試圖通過類加載器,this.getClass()。getClassLoader()。getResource()方法,並確保你有「一致」的對象(例如不在構造函數中) – BigMike 2012-07-11 07:29:00
@BigMike我試過你的解決方案,但結果是一樣的。 – 2012-07-11 07:37:56
發表你的jar文件的jar tvf請 – BigMike 2012-07-11 08:15:08