/home -> /home/articles/ -> /home/articles/J2ME+WTK2.0 --::--

Develop J2ME Applications using WTK 2.0

Author: Rossano Pablo Pinto

Author: Rossano Pablo Pinto (rossano@dca.fee.unicamp.br)
Thu Apr 10 17:17:48 BRT 2003

0. You'll use:

   - J2ME WTK2.0
   - MIDP for PalmOS 1.0
   - emacs
1. Download:

   - j2me_wireless_toolkit-2_0-linux-i386.bin 
   - midp4palm-1_0.zip

2. Install J2ME WTK2.0 under /usr/local/WTK2.0

    - export J2MECLASSPATH=/usr/local/WTK2.0/wtklib/kenv.zip:/usr/local/WTK2.0/wtklib/kvem.jar:/usr/local/WTK2.0/wtklib/lime.jar
    - export J2MEWTK_HOME=/usr/local/WTK2.0

3. Execute: /usr/local/WTK2.0/bin/ktoolbar &

   This tool is used to:

    - Create a new project
    - Compile
    - Run
    - Debug
    - Deploy (generate jar and jad files)

   Obs1.: There is NO tool to EDIT, use emacs...
   Obs2.: There is NO templates...

4. Step-by-step project creation:
   4.1 - Click 
         - Project Name: RPP-WebBrowser
         - MIDlet Class Name: webBrowser.MyBrowser

   Some msgs will be generated on the ktoolbar console:

Creating project "RPP-WebBrowser"
Place Java source files in "/usr/local/WTK2.0/apps/RPP-WebBrowser/src"
Place Application resource files in "/usr/local/WTK2.0/apps/RPP-WebBrowser/res"
Place Application library files in "/usr/local/WTK2.0/apps/RPP-WebBrowser/lib"

   and the window `Settings for project "RPP-WebBrowser"` will be opened.

   LET IT UNMODIFIED for now and click .

   4.2 - cd /usr/loca/WTK2.0/apps/RPP-WebBrowser/src
   4.3 - emacs MyBrowser.java &
       - enjoy programming the new web browser!!! Here's a simple example:

package webBrowser;

import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;

public class MyBrowser extends MIDlet implements CommandListener {

  private Form form;

  public MyBrowser() {
    form = new Form("MyBrowser");
    form.append(new StringItem(null, "MyBrowser MIDP"));
    form.addCommand(new Command("Exit", Command.EXIT, 1));

  public void startApp() {

  public void pauseApp(){}
  public void destroyApp(boolean unconditional) {}

  public void commandAction(Command c, Displayable s) {

   4.4 - Press the  button. Some msgs will appear on the ktoolbar 

Project settings saved
Building "RPP-WebBrowser"
Build complete

   4.5 - Press . It'll open the emulator (a phone) and run the 
         application. The following msgs should appear on the ktoolbar console:

Running with storage root temp.DefaultColorPhone1049977275626
Execution completed successfully
378738 bytecodes executed
25 thread switches
429 classes in the system (including system classes)
1999 dynamic objects allocated (64620 bytes)
1 garbage collections (0 bytes collected)
Warning: Cannot access audio system

5. Ok, It's high time to package it onto a jar file and generate a prc one.
   Let's start with the jar file.

   5.1 - Click Project->Package->Create Package. The following msgs should
         appear on the ktoolbar console:

Project settings saved
Building "RPP-WebBrowser"
Wrote /usr/local/WTK2.0/apps/RPP-WebBrowser/bin/RPP-WebBrowser.jar
Wrote /usr/local/WTK2.0/apps/RPP-WebBrowser/bin/RPP-WebBrowser.jad
Build complete 

   5.2 - Right, let's install MIDP for Palm OS v1.0. It provides:

         MIDP for Palm OS is targeted at Palm OS handhelds (Palm, Handspring, 
           Sony, etc.) running Palm OS version 3.5, and includes the 
           following functionality:

               * A binary release of CLDC and MIDP for the Palm OS platform.
               * A desktop utility for converting MIDlets to PRC files.
               * Built in capability allowing users to set MIDP preferences.
               * Some sample MIDlets.
               * User's Documentation.

         a-) Download (if not done yet) midp4palm-1_0.zip (553,083 bytes) 
         b-) Install it:  
              - cd /usr/local 
              - unzip midp4palm-1_0.zip
                * It'll create the directory /usr/local/midp4palm1.0
                * Synchronize (install) PRCFiles/*.prc files with your Palm
                  (It's the JVM implementation for PalmOS and 
                   application examples)
         c-) Generate a prc file from jad + jar files:

             - Run the converter:
               * cd /usr/local/midp4palm1.0/Converter/
               * java -jar Converter.jar
                 It'll open a window. File->Convert will open another 
                 window. Provide the filename:
                 Click OK. All right, now you have the file:
                 Install it on your Palm device. 

              NOTE: If you Project->Clean, it'll not generate the prc file
                    'cause this tool cleans every jar and class files. To
                    regenerate everything Project->Package->Create Package.

Appendix A - Synchronizing using USB Cradle

      * modprobe visor
      * click Synchronize on Palm
      * pilot-xfer -p /dev/ttyUSB0 -i RPP-WebBrowser.prc

Rossano Pablo Pinto's Home Page :: Enjoy :: Use with moderation
Copyleft 2007 Rossano Pablo Pinto