Wtk introduction (1) -- getting started

Source: Internet
Author: User
J2mwireless Toolkit (wtk) is a commonly used j2msdk. wtk can be used Program . For more information about wtk, see http://java.sun.com/products/j2mewtoolkit.
Currently, the latest version is wtk2.1, which supports jtwi (wireless industry Java technical specifications) Roadmap 1, cldc1.1 and j2-web services APIs. This article mainly introduces the wtk2.0 version, which supports many new technical specifications, such as midp2.0, mobile media API, and wireless message API.
Software Download and Installation
Wtk2.0 requires support for JDK, can be downloaded from the following URL jdk1.4: http://java.sun.com/j2se/1.4.2/downloads/index.html
You can download wtk2.0 from the following URL:
Http://java.sun.com/products/j2mewtoolkit/download-2_0.html
After the download, install JDK and then wtk. When installing wtk, you will be asked about the JDK installation path, as shown in. Please specify the correct JDK path in this step.


Use of the wtk2.0 Environment
After the installation is complete, you can use wtk2.0. Start the ktoolbar. The program is in the wtk20/bin directory. Shows the ktoolbar running window:


On the ktoolbar interface shown in the figure, menus and toolbar are used to execute various functions, including creating a project, opening a project, compiling and generating an application, packaging, and deploying it. The drop-down list box is used to select the simulator used to run the application. The system console output is displayed in the bottom area.
In the ktoolbar, select file | open project or click Open project on the toolbar. The window shown in is displayed. Select a project from the window list, such as photoalbum. Click Open project to open the project.



Shows the ktoolbar after opening the project. Comparing the above ktoolbar interface, we can see that some of the previously unavailable buttons can be used now.


Click Run on the toolbar. The simulator window is displayed. Click Select on the simulator or press enter on the keyboard to select the project running in the simulator. It is a snapshot of an animation application running.


Wtk2.0 provides four simulators with different styles and different skin colors. Besides the default color simulators shown above, it also provides a black-and-white simulator, a media control simulator, and a simulator qwertydevice with a standard keyboard. Use the device drop-down list box on the ktoolbar to select different simulators. Shows the qwertydevice simulator.


The following describes how to use wtk to compile and run your own applications. First, the hello World Program on the mobile phone is provided.
Create source file
Create the file hello. Java with the following content:
Import javax. microedition. MIDlet. MIDlet;
Import javax. microedition. lcdui .*;
Public class Hello extends MIDlet
{
Private display;
Public Hello (){
}
Public void Startapp (){
Display = display. getdisplay (this );
Textbox T = new Textbox ("demo app", "Hello World", 256, 0 );
Display. setcurrent (t );
}
Public void pauseapp (){
}
Public void destroyapp (Boolean unconditional ){
}
}
Compile and run the program
On the ktoolbar page, click New project and enter the data shown in the dialog box that appears.


Click Create project. The project settings window shown is displayed. In this window, you can set various properties of the project. In this case, accept the default settings and click OK]


wtk stores all projects in the wtk20/apps/directory. Check the directory after creating the project. An extra helloworld folder is displayed. The folder contains four file folders: SRC, res, Lib, and bin. "Src" is used to store source files, "res" stores the resource files required by the program, and "lib" stores the library files required by the program, there are no files under the three directories when the project was just created. The "bin" directory contains two files: "manifest. MF" and "helloworld. Jad ". "Manifest. mf is a list file that records various properties of the project, "helloworld. the content recorded by Jad and manifest. similar to MF, this file is used when you use a mobile phone to download Java software from the Internet. The content of both files can be modified using the normal editing program, or in the project settings window shown in. After creating a project, select project | settings ...] Click Settings… on the toolbar ...] You can open the project settings window.
copy the hello. Java file to the helloworld/src directory, and click build on the ktoolbar to compile the source program. If an error occurs in the source program, the console displays the error message. If the compilation is successful, the following information is displayed on the console:
Project Settings saved
building "helloworld"
build complete
after the source program is compiled successfully, click Run on the toolbar to run the program, and click Select on the simulator to enter the program, as shown in.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.