在Java applet中读取.jar文件 [英] Read .jar file in Java applet
问题描述
我有一个小Java小程序游戏,您可以在其中选择一些主题。它工作得很好,但巨大的.jar的下载时间是不可接受的。现在我想将.jar拆分为单个.jars,默认为每个主题一个。现在只有一个问题:(如何)我可以从Java小程序中读取.jar文件,该小程序也是.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?
推荐答案
查看 URLClassLoader
。您可以将theme.jar的URL作为参数提供,并使用getResource *方法访问其中的文件。
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.
另一种方法是手动下载JAR并使用 java.util.jar
类打开它,但是我会采用第一种方法。
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 applet中读取.jar文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!