Is it possible for a J2ME application to open another jar file?
Suppose you download a game (which is a .jar file).
Is it possible to download a second jar file which has only additional assets so that the jar #1 (the application/game) could read files from jar #2 ?
You can download additional assets (assuming you have security permissions to do so; probably the phone will prompt the user to allow the connection, or something), for example by HTTP. Check the MIDP javadoc for class Connector, and interface Connection. (And look at Sun's tutorials too, with those keywords). However, you probably want to leave those resources as whatever plain files, rather than a JAR - because what you're going to receive is an InputStream (or you can send an OutputStream, for that matter), and you have to handle the decoding of input yourself. Some library widgets can make effective use of an InputStream (IIRC in MIDP 2.0 you can use it as a parameter for Image.createImage()), but in general you are stuck doing the hard work yourself. Of course, if your "resource" is a level file for your game or something, then you had to interpret it anyway, so it's the same thing :) You just get your InputStream from a Connection, instead of Class.getResourceAsStream().
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement