我这样称呼我的形象:
ImageIO.read(this.getClass().getResource("../res/image1.gif"));
当我从命令行运行它时,java -jar "testWebStartRes.jar"
我的图像会加载。当我将它部署为 GlassFish 服务器上的 Web 启动应用程序时,从 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 start 应用程序。