»  Home
»  Getting Started
   »  Introduction to J2ME
   »  Working with WTK
   »  Understanding J2ME Midlet
»  J2ME UI
»  LBS
»  Appendix

Username

Password





Working with WTK (Wireless Toolkit)




We will use a step-by-step approach to learn to work with WTK or the Wireless Toolkit. For installation guidance check the appendices. If you are ready let’s begin (the instruction will be Windows based, but it will be similar for other operating systems) –


  1. Run the wireless toolkit. You need to run “/bin/ktoolbar.exe”. For me the path is “C:\WTK22\bin\ ktoolbar.exe”. (Use the correct path for all instructions that follow.) You can go to Start menu, choose programs->j2me wireless toolkit->kToolbar

    The window will look like –

  2. wtk start page
  3. Create a new project named ‘HelloGroup’ and MIDlet class name as ‘HelloMIDlet’ clicking on the “New Project” button –

  4. wtk new project
  5. In the settings window that pops up for the new project, choose CLDC 1.1 in configuration. This is not important for this particular project but it will be necessary for LBS applications.


  6. Now take a look at the directory structure of the J2ME project. Notice that a folder named ‘HelloGroup’ has been created in “C:\WTK22\apps”. All projects are created in ‘apps’ folder of WTK. Inside the folder there are four other folders and a properties file.

    • The properties file stores all the setting you selected while creating the project. You can change it manually or clicking the ‘Settings’ button on the wirless toolkit.
    • The ‘src’ folder contains all the source codes i.e. all java files that you write.
    • The ‘res’ folder contains all the resource files (e.g. images, text files or any file other than java files)
    • The ‘lib’ folder contains any library files i.e. jar files in addition to the default j2me libraries that you might need for particular projects.

    • The ‘bin’ folder will contain files that are required to run your application. Such files include .jar, .jad and .mf files. These files will be generated by the toolkit, so no need to worry about them right now.

  7. Get the source code. We will use a simple HelloMIDlet.java program for the purpose. Download the code by clicking here. Do you know where to place the file? Good, you guessed it right! Place it in the ‘src’ folder. Don’t worry about the code right now; we will analyze it in the next section.

  8. Compile the code. Come back to the wireless toolkit window. Click the “Build” button to compile the project. Be aware that the build process in WTK is not same as a normal java compilation using javac. More about this later.


  9. Look again at the directory structure of the J2ME project. Notice that new folders have been created. The folders ‘tmpclasses’ and ‘tmplib’ are created to store intermediate files during the build process. The final class files are stored in ‘classes’ folder. The ‘bin’ folder now has two files namely ‘HelloGroup.jad’ and ‘MANIFEST.MF’. You can open the files using wordpad or other text editors and find out what is inside. We won’t bother ourselves too much with these now as they are created and updated by WTK. You can have a better understanding later.



  10. Create a jar file by going to project->package->create package. It will create ‘HelloGroup.jar’ in the ‘bin’ folder. If you want the application to run on a device, you need to transfer the jar file to that.

  11. wtk package
  12. Run the application by clicking ‘Run’ button on the WTK window. Bingo! Your first J2ME application runs. Congrats!
    Notice there is a drop-down list below the buttons in the WTK toolbar named ‘Device’ where ‘DefaultColorPhone’ is selected by default. You can change this setting to have a look at how your application works in different devices.


  13. So far we didn’t look into the java code itself. We will now proceed to the next part to discuss the structure and functioning of the J2ME application.




    Use the menu at top-left corner for navigation.


    Created on 01/21/2007 12:08 AM by admin
    Updated on 03/30/2008 06:47 PM by admin
     Printable Version

The comments are owned by the poster. We are not responsible for its content.