Gently J2ME (4) -wirless Toolkit

xiaoxiao2021-03-06  65

Gently J2ME (4) -wirless Toolkit

The previous article has established J2ME applications in JBuilder 9, but I want some friends who have heard the name of JBuilder will be scared by its huge. It is true that my own machine is 128 memory. I ran up JBuilder's slow, I remember it once: I found a program in the evening to change (the second day boss is going to be), not in the company, can only let my machine to run JBuilder, program rewriting It took only a few seconds, but from the run to see the result, I have been waiting for more than a minute, and I haven't done this at night.

Oh, you can see it here, you can be afraid, because in addition to JBuilder, there are still a lot of simple and easy-to-use J2ME development tools, such as WTK (Wiireless Toolkit), which is going to talk about this article is quite good. J2ME development tool. Let's talk about it in detail below:

"Wireless Toolkit" is SUN for the development of the KIDP app for free, although it is functional that cannot be compared to the integrated development environment such as JBuilder, but absolutely uses the sparrow with small, and the five internal organs are fully described.

We must have J2SDK1.3 or more, as for J2SDK installation, I don't say it here, there are also a J2SDK installation in the Internet. It mainly tells J2ME.

First of all, it must be a Wireless Toolkit installer. You can download its installer to Sun's Java Site, or download "J2ME_Wireless_Toolkit-2_1-Windows (2.1 version) on Game.kongzhong.com website, I I don't know if there is a version of 1.0 on the Game.kongzhong.com, but the version of the 2.1 can be used, we will use the version of 2.1 as an example, how Wireless Toolkit develops J2ME applications, as for how to install, I am here I don't say it, because there is nothing special place in the installation, and the method of installing the ordinary Windows program is the same (we are here to explain as an example under Windows, do not introduce under Linux)

My WDK is installed in D: / WTK21 / under, we will see some files and folders in the installation directory, we first introduce the use of several major files or folders.

l Appdb: Place the file of the Record Store generated by all MIDP applications, and related files downloaded through OTA.

l Apps: Store our project files, each project automatically establishes a subdirectory to manage files related to the project.

l bin: Put some tools.

l DOCS: Store some documents.

l lib: Store CLDC / MIDP class libraries and configuration settings files.

l Sessions: The file location stored using the result of the network or memory monitoring function.

l WTKLIB: Store resources related to Wireless Toolkit features and appearance.

l Index.html: It is a reference manual, and the user can query the corresponding class of J2ME according to it.

Understand the framework of the Wireless Toolkit tool, we can start learning how to use it. As shown in Figure (1), we run a Wireless Toolkit development tool. Go to the Wireless Toolket interface, as shown in Figure (2).

figure 1)

figure 2)

Now we can build your own project and write J2ME mobile programs.

First, we click "Fileà New Project" or the "New Project" button directly to create a new item, as shown in Figure (3):

image 3)

Fill in the primary name of the project name and MIDlet, click the "Create Project" button, the interface shown (4) appears: note that the project name here can be willing to be free, but the class name can write with us. The class name when the code is maintained.

Figure 4)

This interface is used to configure some of the property values ​​of the MIDP application, such as using MIDP1.0 or using MIDP2.0, can set it here (regarding the parameter settings of the MIDP application, we will introduce in the next chapter) The friends here directly receive the default form, and "ok" is ok.

Now you go to the apps file in your "Wireless Toolkit" installation directory, is it more than a Test folder than just a Test folder, huh, I think you already know, it is what you built. Project file. Project file is established, now you can write a J2ME program to see, unfortunately "Wireless Toolkit" does not provide an editor's environment, we can only edit text, "NOTEPAD", "EIDTPLUS" Write the code.

Open your text editor, write down the following procedure:

Import javax.microedition.midlet. *;

Import javax.microedition.lcdui. *;

Public class test extends MIDLET

{

Display display;

Form form;

Public test ()

{

Display = display.getdisplay (this);

Form = New form ("first midp");

Form.Append ("HelloWorld!");

}

Public void startApp ()

{

Display.SetCurrent (Form);

System.out.println ("HelloWorld!");

}

Public void pauseApp ()

{

}

Public void destroyApp (Boolean Conditional)

{

}

}

It is best to copy it, because if it is just copy, I can't guarantee whether the program can run. You don't have to consider the details of the program. With the future study, everyone will know the specific meaning of the code. .

Save the above program in the ".java" file in the SRC directory in the project text we have just built, then we click on the "build" button in the interface shown in the picture, "Wireless Toolkit" will automatically compile us. After the original code, after compiling, the generated corresponding file will be placed in the corresponding directory under the project file test, and we will introduce the structure of the project file later.) We can follow (2) The "Run" button runs the program, as shown in Figure (5):

Figure 5)

How, I have written a J2ME app, it is very accomplishment, although this program is simple, but the complex program is combined by a simple code, start your J2ME. Program trip.

supplement:

The structure of the project file:

In the project file, there are several major folders, which contains the main content of the app, which briefly introduces several important folders:

l bin: This folder places JAR files and JAD files. About JAR and JAD files, we will introduce it in our later articles.

l Classes: This file is plugged in to compile the class file, and the program is running from the folder when running.

l Res: This folder mainly stores resource files, such as using a picture in your program, then put the picture in this file, the program will follow the relative path we give in this folder to find pictures .

l SRC: The original code we wrote here is stored.

The introduction of "Wireless Toolkit" is here, the next plan introduces some detailed format descriptions of JAR files and JAD files in the MIDP program.

Easy J2ME (4)

Note: I have found that some websites have provided this article as non-free resources. I hope everyone should not be able to share and make progress together.

转载请注明原文地址:https://www.9cbs.com/read-88527.html

New Post(0)