在签名 Jar、JNLP 应用程序中加载图像时出错
我正在开发 JNLP 应用程序并使用 maven-webstart 插件来创建 JNLP。在本地运行应用程序时,它可以正常工作,但是当我使用 jnlp 在 Tomcat 服务器中运行时,它不会加载图像,也不会给出任何异常。
我正在加载图像,如下所示
new ImageIcon(getClass().getResource("/icons/save.png"))
我的代码有什么问题吗?
I am developing JNLP Application and using maven-webstart plugin to create JNLP. When running the application in my local, it works correctly but when I run in Tomcat Server using jnlp, it does not load images and also does not give any exception.
I am loading images as below
new ImageIcon(getClass().getResource("/icons/save.png"))
What is wrong with my code?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你的图标位于哪里?如何在 tomcat 中运行 jnlp 应用程序?假设您没有很多图像,您可以将它们打包到您的一个包中。只需创建一个名为 com.yourproject.resources 的包并在其中转储一些图像即可。那么访问它们的方法是:
//在某个类中定义它
请使用 URL 获取它们。
然后创建您需要的东西:
注意一些事情:在我的设置中,您需要将图像打包到 jar 中。
Where are your icons located? How do you run a jnlp application inside tomcat? Assuming you don't have a lot of images, you can package them inside one of your packages. Just create a package called com.yourproject.resources and dump some images there. Then the way to access them would be:
//define it in some class
Do get them with a URL.
Then to create the stuff you need:
Note some things: In my setup you need to package your images into your jar.
如果没有更多信息,很难说。您可以使用
jar -tf
来查看图像是否在 JAR 文件中。同时,这里有一个可以加载图像的 JWS 应用程序,供参考。It's hard to say without more information. You might use
jar -tf
to see if the images are in the JAR file. In the meantime, here's a working JWS application that loads images, for reference.