通常一个MIDlet程序有两个运行时属性,系统的和程序的(system and application)。这些属性都只能读取,不能修改。
系统属性
系统的属性一般是由设备定义的。在各个jsr标准中定义了一些系统属性的键值(key)。附1的表格就列出了当前的一些已经定义的系统属性名。
读取方法:System.getProperty() ,这是一个静态方法
程序属性
程序属性是在程序的描述文件中和jar包的manifest文件中定义。附2中就就是一个典型的描述文件。假如同样的属性在描述文件中和manifest文件中都被定义了,冲突会这样被处理:假如MIDlet是一个MIDP2.0的可信任的程序,系统会直接拒绝安装程序。否则,程序描述文件中定义的值会覆盖manifest中定义的属性。(If the MIDlet is a trusted application based on MIDP 2.0, the system simply won't install the application. Otherwise, the value in the descriptor overrides the value in the manifest.)
读取方法:MIDlet.getAppProperty(),这是一个实例方法
注意:1、这些属性的名称是区分大小写的。2、假如获取一个没有定义过的名称,会返回一个null值。3、不要定义太多的属性,有些设备上的描述大小是有限制的。
原文参看:http://developers.sun.com/techtopics/mobility/midp/ttips/appproperty/index.html
附1:
J2ME Defined System Properties
| JSR | Property Name 
 | Default Value¹ | 
| 30 | microedition.platform | null | 
|  | microedition.encoding | ISO8859_1 | 
|  | microedition.configuration | CLDC-1.0 | 
|  | microedition.profiles | null | 
| 37 | microedition.locale | null | 
|  | microedition.profiles | MIDP-1.0 | 
| 75 | microedition.io.file.FileConnection.version | 1.0 | 
|  | file.separator | (impl-dep) | 
|  | microedition.pim.version | 1.0 | 
| 118 | microedition.locale | null | 
|  | microedition.profiles | MIDP-2.0 | 
|  | microedition.commports | (impl-dep) | 
|  | microedition.hostname | (impl-dep) | 
| 120 | wireless.messaging.sms.smsc | (impl-dep) | 
| 139 | microedition.platform | (impl-dep) | 
|  | microedition.encoding | ISO8859-1 | 
|  | microedition.configuration | CLDC-1.1 | 
|  | microedition.profiles | (impl-dep) | 
| 177 | microedition.smartcardslots | (impl-dep) | 
| 179 | microedition.location.version | 1.0 | 
| 180 | microedition.sip.version | 1.0 | 
| 184 | microedition.m3g.version | 1.0 | 
| 185 | microedition.jtwi.version | 1.0 | 
| 195 | microedition.locale | (impl-dep) | 
|  | microedition.profiles | IMP-1.0 | 
| 205 | wireless.messaging.sms.smsc | (impl-dep) | 
| 205 | wireless.messaging.mms.mmsc | (impl-dep) | 
| 211 | CHAPI-Version | 1.0 | 
附2
MIDlet-1: HttpWrapperMidlet,,httpwrapper.HttpWrapperMIDlet
MIDlet-Jar-Size: 16315
MIDlet-Jar-URL: HttpWrapper.jar
MIDlet-Name: HttpWrapper
MIDlet-Vendor: Vendor
MIDlet-Version: 1.0
MicroEdition-Configuration: CLDC-1.0
MicroEdition-Profile: MIDP-1.0
Which-Locale: en