Back Tabla de contenidos
Next
Capitulo 7.3: Ejemplos practicos (MIDlets)

Todos los ficheros necesarios para un MIDlet es lo que se denomina MIDlet Suite y en concreto se compone de:

Además, hay un software dependiente del dispositivo y suministrado por el fabricante que es el encargado de instalar, ejecutar y borrar el MIDlet del dispositivo. Este software se denomina Application Manager.

Para poder ejecutar este primer ejemplo hemos creado el fichero setShowProperties.bat en el directorio c:\midp-fcs\classes donde se puede ver la estructura de directorios y los pasos a seguir:

            rem set showProperties environment
            set PATH=%PATH%;c:\midp-fcs\bin
            set CLASSPATH=%CLASSPATH%;c:\midp-fcs\classes
            echo **** compile ****
            javac -bootclasspath c:\midp-fcs\classes showProperties.java
            echo **** preverify ****
            preverify -classpath c:\midp-fcs\classes;. -d . showProperties
            echo **** JAR File ****
            jar cvfm showProperties.jar manifest.mf showProperties.class showProperties
 

Ejemplo-1: showProperties

1) Fuente java: 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) {}
    }

2) Fichero manifiesto: manifest.mf

    MIDlet-Name: Show Properties MIDlet
    MIDlet-Version: 1.0.1
    MIDlet-Vendor: Corporation.
    MIDlet-1: ShowProps, showProperties
    MicroEdition-Profile: MIDP-1.0
    MicroEdition-Configuration: CLDC-1.0
    MIDlet-Description: Un simple ejemplo de listado de propiedades.
    MIDlet-Data-Size: 1500

3) Fichero JAD: showProperties.jad

    MIDlet-Name: Show Properties MIDlet
    MIDlet-Version: 1.0.1
    MIDlet-Vendor: Corporation.
    MIDlet-Jar-URL: file://showProperties.jar
    MIDlet-Jar-Size: 1132
    MIDlet-1: ShowProps,  , showProperties
    JadFile-Version: 1.5
    MIDlet-Data-Size: 500

4) Ejecutar el MIDlet:

    midp -descriptor showProperties.jad
 
 

 
Top Back Tabla de contenidos
Next