Configure the mobile app development environment-wtk

Source: Internet
Author: User
Tags ultraedit

The first step in the development of mobile phone applications based on the J2EE platform is to select a good development tool. Mobile phone program development is very different from PC program development. PC programs can be directly developed and run tests on PCs, but on mobile phones, it is certainly impossible to provide application development and integration environments and test tools. Generally, we first use the Java Development Tool on the PC to write the source code and use the Java compiler and the library to generate a program for the j2_cell phone, and then upload the program to the mobile phone for running. Currently, most mobile phone manufacturers provide Simulators of different models. This simulator can run directly on a PC to simulate the j2_runtime environment provided on this mobile phone. If the mobile phone simulator is installed, you can directly test the compiled mobile phone program on the PC simulator, and then upload the program to the real machine after the test runs normally.

Although many tools can be used to develop the j2's mobile phone program, many of them have powerful JBuilder integrated development environments, but for beginners, it is better to use ultraedit/notepad + wtk as a development tool for Mobile Phone programs. Both ultraedit and notepad are commonly used editing software on the PC. We can use them to compile the code of the mobile phone program, and then use the wtk provided by Sun (j2_wireless Toolkit) compile, simulate, and upload the source code to the VM. The following describes how to install and use wtk.

1.Install wtk

Wtk, short for j2mwireless toolkit, is developed by Sun to support the development of devices (such as mobile phones, two-way pagers, and PDAs) that are compatible with the mobile information device framework (MIDP) java application. The current wtk version is later than Version 2.0. It supports the latest midp2.0. You can download and install wtk from the sun website. The following describes how to download and install wtk.

(1) log on to the Chinese version of Sun j2wtk to download the webpage:

Http://java.sun.com/products/j2mewtoolkit/zh_download-2_0.html.

(2) The Chinese version is implemented through local patching. First, download the English version of wtk2.0, as shown in figure 3, select the operating system type installed on your PC in the list box. (generally, most PCs use Windows. This document uses Windows as an example. For details about other platforms, see .), Click the first "continue" button.

 


Figure 1: Download wtk2.0
Page Diagram

(3) If you are not logged on, you will be prompted to log on. If you have not yet become a sun member, you can register a member immediately. The logon process is similar to that of other website Members.

Bytes, Which is 9.89 m in size.

 


Figure 2: wtk2.0
Part of the English version File Download Page

(4)、run the j2me_wireless_toolkit-2_0-windows.exe Installer. When the system prompts you to provide the installation directory, make sure that the path of the installation directory is completely legal and does not contain any spaces. This will help you avoid possible problems when using the Toolkit in the future.

(5) After the English version of wtk2.0 is installed, go back to figure 3 and click the second "continue" button to download the Chinese patch file. Bytes, Which is 4.07 m in size.


 

Figure 3: wtk2.0Part of the Chinese patch File Download Page

(6)unzip the j2me_wireless_toolkit-2_0-zh.zip file to the installation directory in the English version of wtk2.0 (the default installation directory is C:/wtk2.0) to ensure that the file is extracted with the directory path.

(7) The Chinese version of wtk2.0 is successfully installed.

2.Use wtk

If wtk is successfully installed, select "program-> j2e-wireless toolkit2.0-> ktoolbar" from the Start menu to start the wtk tool program, as shown in page 6.

 


Figure 4: wtk
Run Interface

Wtk provides the following functions: Create a project, open a project, generate a project, and run a project.

Create a project

Before writing a mobile phone program, you must use wtk to create a new project. To create a project, follow these steps:

(1) Click "Create Project" in the toolbar to bring up the "Create Project" dialog box, as shown in figure 7.

 


Figure 5: New Project dialog box

(2) enter the project name, such as myprogram, in the "Project name" column. In the "MIDlet class name" column, enter the main class name of your mobile phone program, such as mymidlet, in the subsequent sections, we will introduce that each cell phone program with a Child class of the MIDlet class must have a Child class.

(3) Click the "generate project" button to bring up the "project configuration" dialog box. In this dialog box, you can modify the configuration of the Project, which generally does not need to be modified.

(4) Click "OK" to create a project. Note that the path of the Project Java source file, resource file path, and library file path are listed in the main window. During wtk program generation, the path structure of the project must be standardized; otherwise, the running program cannot be generated.

Figure 8 shows the path structure under the wtk directory after the myprogram project is generated. Wtk creates a subdirectory with the same name for each project under its subdirectory apps, and creates four directories, bin, SRC, res, and Lib, in which the bin directory is used to store the target program, when you use the generation tool to generate a runnable program, there are usually *. jar and *. the specific significance of the JAD file will be detailed in the following sections; the src directory is used to store the source code; the res directory is used to store the resource files; and the lib directory is used to store the auxiliary library files called by the program.

 


Figure 6: wtk
Project pathOpen a project

Open a project opens an existing project as the current work project of wtk. Click the open project button to bring up the open project dialog box. You can select Open project from the project list. Note that only projects in the apps directory can be selected in this project list. If your project is not in this project, you cannot use wtk to open the project.

Generate a project

After you create a new project and write the source code or open the old project, you can click the "generate project" button on the toolbar. wtk will automatically call the Java compiler to compile the project program. If the program code has syntax errors, an error prompt will be generated in the main window. Otherwise, the *. jar and *. Jad target files will be generated for the project.

Run the project

After the project target file is generated, click the "run project" button on the toolbar. wtk starts the simulator and loads the *. jar and * Jad files under the project bin directory. The Simulator Interface looks similar to the corresponding model. You can use the keyboard on the simulator to operate the project program. Figure 9 shows the running result of the pushpuzzle game on the simulator.

 


Figure 7: pushpuzzle
Game running result graph on Simulator

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.