在Java小程序中读取.jar文件

发布于 2024-10-01 06:16:38 字数 147 浏览 0 评论 0原文

我有一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

浮生未歇 2024-10-08 06:16:38

看一下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.

栖迟 2024-10-08 06:16:38
  1. 使用 Java Web 部署小程序
    开始。从 Java 1.2 开始,这可能是
    完成以获得“自由浮动”小程序
    (在网页之外),但是自从
    1.6.0_10+,对于嵌入式小程序也可以这样做。
  2. 将每个主题放入
    一个单独的 Jar 并在 JNLP 中
    (启动文件)&将它们标记为“懒惰”
    下载。
  3. 注明是哪个包
    包含在哪个 Jar 中(也在
    JNLP 文件)以便 JWS 客户端知道
    分别下载哪个 Jar
    主题。 (a)
  4. 其他一切都会“像魔术一样”工作,并且 JWS 客户端在下载惰性 Jars 时将显示进度条。

(a) 为了使其正常工作,每个主题都需要位于单独的包中,以及单独的 Jar 中。

  1. Deploy the applet using Java Web
    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.
  2. Put each theme in
    a separate Jar and in the JNLP
    (launch file) & mark them as 'lazy'
    download.
  3. Notate which package is
    contained in which Jar (also in the
    JNLP file) so the JWS client knows
    which Jar to download for each
    theme. (a)
  4. Everything else will work 'like magic', and the JWS client will show a progress bar when downloading the lazy Jars.

(a) For this to work properly, each theme needs to be in a separate package, as well as a separate Jar.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文