列出 webstarted 应用程序的 jar 中的所有文件
给定一个由多个 jar 组成的 webstart 应用程序,我如何列出这些 jar 中包含的文件? (在运行时)
提前致谢,
Arnaud
编辑:
下面提到的方法(与我到目前为止使用的非常相似)的问题是,在调用 webstart 时类路径会以某种方式发生变化。事实上,它不再引用您的 jar,而是引用一个 deploy.jar
。
因此,如果您运行 java -cp myjars test.ListMyEntries ,它将正确打印 jar 的内容。另一方面,通过 webstart,您将获得 deploy.jar
的内容,因为这是 webstart 时定义类路径的方式。我没有在任何系统/部署属性中找到任何原始 jar 名称的痕迹。
输出样本:
Entries of jar file /usr/lib/jvm/java-6-sun-1.6.0.06/jre/lib/deploy.jar
META-INF/
META-INF/MANIFEST.MF
com/sun/deploy/
com/sun/deploy/ClientContainer.class
com/sun/deploy/util/
com/sun/deploy/util/Trace$TraceMsgQueueChecker.class
Given a webstart application composed of multiple jars, how could I list the files contained in these jars? (at runtime)
Thanks in advance,
Arnaud
EDIT:
The problem, with the method mentionned below (which is very similar to what I used until now), is that somehow the classpath changes when invoking webstart. Indeed, it doesn't reference your jars anymore but a deploy.jar
instead.
As a consequence, if you run java -cp myjars test.ListMyEntries
it will correctly print the content of your jars. On the other hand, via webstart, you will obtain the content of deploy.jar
because this is how the classpath is defined when webstarted. I did not found any trace of the original jar names in any of the system/deployment properties.
Output sample:
Entries of jar file /usr/lib/jvm/java-6-sun-1.6.0.06/jre/lib/deploy.jar
META-INF/
META-INF/MANIFEST.MF
com/sun/deploy/
com/sun/deploy/ClientContainer.class
com/sun/deploy/util/
com/sun/deploy/util/Trace$TraceMsgQueueChecker.class
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
是的,你可以..但是你应该对类所在的 jar 进行签名并授予所有权限..
Yes you can.. But you should sign the jar that class resides and give all permissions..
如果我们可以通过磁盘访问这些 jar(我认为我们应该有),那么 jdk 的 JarFile 类可用于打开和迭代 jar 文件的内容。 Entrys 方法返回的 Enumeration 中包含的每个条目都是 jar 中的类名。
If we have disk access to these jars (which i think we would have) then jdk's JarFile class can be used to open up and iterate over the contents of a jar file. Each entry contained in Enumeration returned by entries method is a class name within the jar.
您是否尝试过使用
或者,您可以使用 JMX :
Have you tried using
Alternately, you can use JMX :
我就是这样做的:
This is how I did it: