在Java小程序中读取.jar文件
我有一个 Java 小程序游戏,您可以在其中选择一些主题。它工作得很好,但巨大的 .jar 的下载时间令人无法接受。现在我想将 .jar 拆分为单个 .jar,每个主题一个默认的一个。现在只有一个问题:(如何)我可以从同样是 .jar 的 Java 小程序读取 .jar 文件吗?
I have a little Java applet game where you can choose between some themes. It works very well but the downloading time of the huge .jar is not acceptably. Now I want to split the .jar into single .jars, a default one and one for every theme. Now there is just one question: (How) can I read a .jar file from a Java applet which is also a .jar?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看一下
URLClassLoader
。您可以将 URL 作为 theme.jar 的参数,并使用 getResource* 方法访问其中的文件。另一种方法是手动下载 JAR 并使用 java.util.jar 类打开它,但我会采用第一种方法。
Take a look at the
URLClassLoader
. You can give the URL to the theme.jar as a parameter and use the getResource* methods to access the files inside.Another approach would be to manually download the JAR and open it with the
java.util.jar
classes, but I would go with the first approach.开始。从 Java 1.2 开始,这可能是
完成以获得“自由浮动”小程序
(在网页之外),但是自从
1.6.0_10+,对于嵌入式小程序也可以这样做。
一个单独的 Jar 并在 JNLP 中
(启动文件)&将它们标记为“懒惰”
下载。
包含在哪个 Jar 中(也在
JNLP 文件)以便 JWS 客户端知道
分别下载哪个 Jar
主题。 (a)
(a) 为了使其正常工作,每个主题都需要位于单独的包中,以及单独的 Jar 中。
Start. From Java 1.2 this could be
done to get a 'free floating' applet
(outside a web page), but since
1.6.0_10+, it can also be done for embedded applets.
a separate Jar and in the JNLP
(launch file) & mark them as 'lazy'
download.
contained in which Jar (also in the
JNLP file) so the JWS client knows
which Jar to download for each
theme. (a)
(a) For this to work properly, each theme needs to be in a separate package, as well as a separate Jar.