我这样称呼我的形象:
ImageIO.read(this.getClass().getResource("../res/image1.gif"));
当我从命令行java -jar "testWebStartRes.jar"
运行此图像时,我的图像会加载。
当我将它作为Web启动应用程序部署在GlassFish服务器上时,从JNLP启动它时找不到图像。
堆栈追踪:
Detected from bootclasspath: C:\\Program Files\\Java\\jdk1.7.0\\jre\\lib\\deploy.jar
java.lang.IllegalArgumentException: input == null!
at javax.imageio.ImageIO.read(ImageIO.java:1388)
at main.Main.setAppIcon(Main.java:42)
at main.Main.<init>(Main.java:19)
at main.Main$1.run(Main.java:34)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:705)
at java.awt.EventQueue.access$000(EventQueue.java:101)
at java.awt.EventQueue$3.run(EventQueue.java:666)
at java.awt.EventQueue$3.run(EventQueue.java:664)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:675)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:211)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
Null Image
编辑:让问题更容易理解。 Andrew Thompson解决了如何使用单独的jar部署Web启动应用程序。