MIDlet Packaging with J2ME
Pages: 1, 2, 3, 4, 5
What follows is a short example to print various attributes from both those files.
manifest.mf is stored as part of
showProperties.jar:
MIDlet-Name: Show Properties MIDlet
MIDlet-Version: 1.0.1
MIDlet-Vendor: My Corporation Inc.
MIDlet-1: ShowProps, , showProperties
MicroEdition-Profile: MIDP-1.0
MicroEdition-Configuration: CLDC-1.0
MIDlet-Description: A simple property list example
MIDlet-Data-Size: 1500
Contents of showProperties.jad:
MIDlet-Name: Show Properties MIDlet
MIDlet-Version: 1.0.1
MIDlet-Vendor: My Corporation Inc.
MIDlet-Jar-URL: file://showProperties.jar
MIDlet-Jar-Size: 1132
MIDlet-1: ShowProps, , showProperties
JadFile-Version: 1.5
MIDlet-Data-Size: 500
Contents of showProperties.java:
import javax.microedition.midlet.*;
public class showProperties extends MIDlet
{
public void startApp() throws MIDletStateChangeException
{
System.out.println("Vendor: " + getAppProperty("MIDlet-Vendor"));
System.out.println("Description: " + getAppProperty("MIDlet-Description"));
System.out.println("JadFile Version: " + getAppProperty("JadFile-Version"));
System.out.println("MIDlet-Data-Size: " + getAppProperty("MIDlet-Data-Size"));
}
public void pauseApp()
{ }
public void destroyApp(boolean unconditional)
{ }
}
|
Here are a few important points:
- The file
manifest.mfis stored as part of the JAR fileshowProperties.jar showProperties.jaris referenced from the JAD fileshowProperties.jadwith the line,MIDlet-Jar-URL: file://showProperties.jar- When you preview the JAD file, it locates the associated JAR file with the line from above and reads the contents of the manifest file.
- The attributes
MIDlet-Name,MIDlet-VersionandMIDlet-Vendorare in both the manifest file in the JAR and the JAD file. All the values are required to be identical. - The attribute
MIDlet-Descriptionis from the manifest file and is optional. - The attribute
JadFile Versionis not in Table 1 and, thus, is a user-defined attribute. Because attributes inside a JAD file are accessible from a MIDlet, you can add attributes to the JAD without having to change the JAR file. Put another way, you can easily change or add parameters to be passed to the MIDlet. - The attribute
MIDlet-Data-Sizeis in both the manifest and the JAD file. As pointed out earlier, when there are identical attributes in both files, entries in the JAD file will take precedence. Thus, output in figure Figure 1 showsMIDlet-Data-Sizeas 500, the value from the JAD file. Keep in mind that this does not apply toMIDlet-Name,MIDlet-Version, orMIDlet-Vendor, which are required to be in both files and must be identical.
