J2ME development and application of JBUILDER tools

xiaoxiao2021-03-06  116

J2ME Development and JBuilder Tools - Reprinted from Java Research Organization [Abstract] In-depth research on J2ME architecture and MIDP application development process, summed up the basic processes and methods development of MIDP applications, the selection of development tools It compares. As a typical Java IDE tool, JBuilder provides powerful MIDP development capabilities in conjunction with JBuilder MobileSet 2.0, and continues on how to develop MIDP development using jbuilder combined with MobileSet, and summarize the characteristics of using JBuilder tools. The essential. [Key words] J2ME, CLDC, MIDP, JBUILDER, MobileSet have two major technical applications in wireless communication, one is broadband CDMA technology, one is IP technology. The former gives wireless communication to get more bandwidth, 3G target is to reach 2Mbps, and now 2.5G technology (such as GPRS and CDMA2000 1x in China) reach 115kbps; the latter makes wireless communication and Internet integration Get up, actually WAP2.0 technology adopts the already mature TCP, TLS, and HTTP protocols, while mobile IP and IPv6 technology will prompt more devices to access the Internet, such as various devices, home appliances, etc. Just in such an environment, J2ME technology is developed rapidly. J2ME is used to provide application development platforms and execution environments for accessing and access to the Internet. This article mainly discusses how to use JBuilder for fast J2ME application development. 1. J2ME hierarchical structure and MIDP brief mesh J2ME is Sun's Java2 platform micro version (one of the three versions of the Java2 platform, the other is the standard version J2SE and Enterprise J2EE), using a 3-layer structure design. The minimum layer is configured, including both virtual machines (VMs), and class libraries, this layer is closely related to device layer (hardware and operating system) relationship, with reference specification and source code, device manufacturers according to device characteristics Perform a corresponding transplant. Current J2ME provides two configurations: Connection Device Configuration (CDC) and Limited Connection Device Configuration (CLDC). The former is mainly for equipment with large memory and processing, such as TV set boxes, refrigerators, automotive navigation equipment, etc., these devices have demand for connecting networks and mutual interactions, with 2M or more; Handheld devices that are mainly restricted to memory and processing capabilities, such as mobile phones, PDAs, etc., now and most of these devices have been able to access the Internet, with a memory range of 160KB (128KB for virtual machines and The class library, at least 32KB is used for the application stack space required by the CLDC specification to 2M. The two main differences in providing the storage space of VM and applications. The VM and class libraries used in CDC are actually referring to the J2SE standard, except for unwanted functions such as AWT. The VM (referred to as KVM) used in CLDC, including the class verification mechanism. For next-generation mobile terminal devices such as smart phones, high-end PDAs, the object applied to the CDC because they will have more than 2m memory. The device layer is a profile, and then the application layer is an application layer (APP). The brief surface extends the configuration layer feature provides an API for the upper layer application. If the configuration level is configured to the device, the brief surface is applied. A variety of briefs can be provided on the CDC or CLDC as needed, and there are also multiple profiles above a configuration layer.

The current CDC has a foundation profile and FP-based Personal Profile and RMI profile. Above the CLDC is mainly provided with a SMS, which is an applet table for mobile terminals such as mobile phones, PDAs, providing API to support wireless applications. Part of the CLDC class is from J2SE. This part of the class library is cut. In addition to unnecessary functions, it mainly includes system classes, data types, exception handling classes, java.util packages, collection classes, Java.util packages. Time and additional tool classes, Java.IO package I / O treatment classes. CLDC's exclusive class is mainly "Universal Connection Framework (GCF)", providing network connection functions for CLDC, which is subclass of the Connection class, called by the method provided by class Connector, these interfaces or classes are available in Package Javax .microedition.io. The CDC class library is a CLDC superchard, so applications developed for CLDC can be transplanted to the CDC platform. Because the CDC uses standard J2SE VM, it is consistent with the development and standard J2SE development, just compiling the source code with JavaC tool. You need to use the CDC class library, just point to the CDC class library with the -bootclasspath parameter. The MIDP extends the ability of the CLDC that inherits GCF and adds classes to the HTTPConnection to provide HTTP connection (although theoretically CLDC / MIDP can provide Socket, Data News, File, NFS and other connection types. But now the standard CLDC / MIDP only supports the HTTP protocol, some device implementation provides support for the Socket and HTTPS protocols), and the MIDP class library is summarized as follows: java.io, java.lang, java.util, belonging to the core package of MIDP , Used to provide system I / O, language support and tool support, respectively. The classes in the package come from CLDC and slightly increased, but all from J2SE. Javax.microedition.midlet, define the MIDP application, and the application and its interaction therefrom. Javax.microEdition.lcdui provides the user interface API for the MIDP application. Javax.microEdition.rms, is used to provide persistent storage for MIDlet, and applications can store data and get these data when needed. Javax.microedition.IO provides network support based on CLDC Universal Connection Framework. 2. MIDP application development J2ME wireless application development here is based primarily based on CLDC / MIDP development, and its application can run mobile phones, PDAs, PDAs, etc., such as MIDP, ie mobile information devices (MID). ), Can be seen as a vertical application market. The MIDP application can be developed on the PC (Windows, UNIX or Linux platform), compiled into class file form, download it to the target device, and verify the authentication of class files (verify that there is a way to call the KVM specification) Explanation execution. From the source code to the final application, the entire process is as follows: Figure 1 MIDP application development process This is the completion step development of a MIDP application, where 8 and 9 can be performed on the simulator, or you can pass the application through IRDA , One of the RS232 or OTAs and other means is running on the target device.

1, 2 steps are written source code on the basis of the previous design, where the resource file can be a PNG image or custom structure data, and the external class library should be in line with the CLDC / MIDP specification (ie, there is no class or method call to CLDC / MIDP). The zip or jar file. There is at least one of the generated .java files to extend the subclass of the javax.microedition.midlet.midlet class, and implement several specified interfaces, such as one of the following MIDlet programs: import javax.microedition.midlet. *; // program life cycle, and J2SE as the default package java.lang * is loaded import javax.microedition.lcdui *;.. // MIDP user interface public class FirstMIDlet extends MIDlet implements CommandListener {private Display display; // references the MIDlet Display Object private TextBox textBox; // Textbox displays a message private Command cmdExit; // setting button for exiting MIDletpublic FirstMIDlet () {// MIDlet constructor display = Display.getDisplay (this); cmdExit = new Command ( "exit" Command.screen, 1); TextBox = New TEXTBOX ("My First MIDlet", "Hello, J2ME!", 50, 0); TextBox.addcommand (cmdexit); TextBox.setCommandListener (this);} public void StartApp ) {// The interface that must be implemented, the application management software call to start MIDletDisplay.setCurrent (} public void pauseapp ()} // The interface that must be implemented Public Void DestroyApp (Boolean Unconditional) {} // The interface that must be implemented Public Void CommandAction (Command C, Displayable D) {// Checks if you select an exit command if (c == cmdexit) {destroyApp (false); notifyDestroyed ();}}} This is the easiest Functual MIDlet application, where interface startapp, paus EAPP, DESTROYAPP is to be implemented, the Application Manager (JAM) calls and controls the application through these interfaces, similar to applet. In addition to this primary class, there can be other auxiliary classes, which requires the J2SE. The Javac tool is then compiled using JavaC tools from J2SE, at least JDK version 1.3, which should be used to compile-BootClassPath and point to the MIDP class library. After the preverify tool is pre-verified to ensure that the generated .class file meets the CLDC requirements, this step adds a stack mapping for each class file (STACKMAP, this property is a new definition of the new definition) attribute, increase the size of about 5%.

At this point, you can use the MIDP tool (executable from the MIDP implementation) to simulate the run, it can be packaged, you need to write a list file (inventory file reference CLDC / MIDP specification), use the JAR tool (from J2SE) to pre-verification Class files, resource files, inventory file packages. To publish an application, you need to write a description file (JAD). JAD's requirements are consistent with the list file, you can customize the parameter supply program call. One of the parameters MIDlet-jar-url points to the JAR file in the URL, the mobile terminal device acquires JAD through the JAM connection network, download the MIDlet-JAR-URL point to the JAR to the device, usually JAM must first determine if the JAD is consistent with the manifest file. Whether the application is valid before deciding to download. Running Environment, JAR Package, JAD File, and Application Lifecycle, these elements constitute the MIDlet kit, managed by JAM, each MIDlet kit can contain one or more MIDlets. The above is a key point of MIDP application development. The specific development methods and development tools are roughly divided into the following: I. Basic development tools The most basic development method is to download the CLDC / MIDP reference implementation and source code provided by Sun. Compile a CLDC / MIDP implementation based on demand and port it to the device. After configuring the development environment (CLDC / MIDP implementation, JDK1.3), the above method and tool can be used to develop, multi-use command line mode, this is the most original method. II. J2MEWTK Development Tool This is the convenient development tool provided by Sun for Windows, which is also necessary to install JDK1.3 first. The source program still needs to use a regular text editor, put the edited source file and resource files in a specified directory, and the J2MewTK is provided with the command of the menu or button mode. There is a corresponding compilation (and pre-verified step), package, analog run menu (or button), and other auxiliary tools. III. IDE tools can be used using Ide tools such as Forte for Java, JBuilder, and J2MewTK integration, which provides visualized development tools in addition to J2MEWTK. 3. Using JBuilder MobileSet JBuilder is one of the common tools for Java programmers lies in its powerful visual programming tools, integrated compilation, run, and debugging environments. To provide JBuilder to provide J2ME wireless application development support, you need to install MobileSet on the JBuilder, it is recommended to install version 2.0, currently supporting version 1.0.3 of CLDC / MIDP, and JBuilder's version should be 6. JBuilder MobileSet 2 Free download: http://www.borland.com/jbuilder/mobileset/JBuilder/MobileSet / also download the appropriate MobileSet serial number and license key (free), install the mobileSet and register, run JBuilder will find the "Help | MobileSet Guilde" menu item. Use the menu "File-> New ..." to open the "Object Gallery" dialog box, there will be a new page label "micro". At this time, "MIDET" and "MIDP Displayable" are gray, only one MIDP project is generated. These two icons can be used later.

3.1 JBuilder MobileSet is an open tool that is integrated with the J2ME development kit provided by other vendors. The current support for the following manufacturers toolkits: Sun offers J2ME Wireless Development Kit 1.0.3 (J2MEWTK) Nokia J2ME Development Kit (http://forum.nokia.com) Siemens SMTK Development Kit (http://www.siemens-mobile.de) where J2mewtk is already included in the installation file of MobileSet 2, If you want to use the development class library provided by J2MewTK, you have not installed J2MEWTK, you can choose to completely install when installing MobileSet 2. MobileSet 2 provides the following auxiliary development tools: CodeInSight tool class / package browser JDK conversion tool for CLDC / MIDP classes Dynamically adapted to any J2ME brief, including MIDP, and develop other Java applications, JBuilder provides through MobileSet Rapid development template, including MIDP project template, MIDP Displayable Template, MIDlet template. It provides a visual designer of RAD (fast application development), supports MIDP UI elements. The MIDP application packaging and OTA configuration is also supported over MobileSet (over the air, upload, and downloading files and MIDlet kits to configure applications to devices). MobileSet is able to use the Personal Edition, Expert Edition and Enterprise Edition in JBuilder, but some functions cannot be used in personal version such as JDK settings to switch, packer, etc. 3.2 Configuring the JDK The previously referred to compiling the MIDP application needs to set a specific CLDC / MIDP class library to avoid using the default J2SE library, and similar settings are also available in JBuilder. This is implemented through the JDK configuration option, JBuilder's design is independent of JDK, although the new JDK (class library) is installed by default when each JBuilder version is published, but it is also possible to set other JDK through its configuration mechanism. Older versions, update the version or OEM version of JDK, so that the JBULDER scalability is implemented. The expert version and the Enterprise version of JBuilder can configure multiple JDK simultaneously, set one of them as needed, and the personal version is to reconfigure each JDK when needed. After installing the mobileSet, you can choose to install J2Mewtk, Nokia and Siemens, and then customize a name for each JDK set, and point your home directory to the parent directory of this JDK / bin, you need to pay attention to the JDK directory. Space such as C: / Program Files / J2mewtk. 3.3 MIDP project JBuilder development is centered on project concept, project file contains a list of (belonging to this item) file list and project properties, where project properties include project templates, default paths, class libraries, and connection configurations, JBuilder uses this information. Load, save, compile and run the project. Use the JBuilder development environment to add, remove files, or settings, and change the project files. The project file can be seen as the primary node in the project panel. The purpose of generating projects is to use the project template tool to set the project name, type, and template, and JDK, working directory, backup path, and compiler. The project type can be selected .jpx or .jpr, the same content, the difference is that the former uses the XML format file, so it is suitable for the shared item.

JDK is one of the previous settings and only the JDK selecting CLDC / MIDP can use the Micro option in Object Gallery. At least one MIDlet primary class for each project, so you should first use the MIDlet template to generate a MIDlet primary class. With the template, you can set the class name, title, screen type, and command processing method, where the screen type has 4 options: (javax.microedition.lcdui.) Canvas, Form, List, TextBox, only Form's extended classes Add other components (subclasses of Item). There are 4 options for command processing: I. - Sets CommandListener, such as MIDlet classes through other classes.

II. INTERFACE IMPLEMENTATION - Generates a class and implements a CommandListener interface in a class. The size of the class generated in this manner is small than the adapter.

III. STANDARD Adapter - This method is generated in the form of a standard adapter:

Class foo {

Private void jbinit () {

AddListener (New Adapter (this));

}

}

Class adapter {

...

}

IV. Anonymous Adapter - This method is generated in the form of anonymous adapter:

Class foo {

Private void jbinit () {

AddListener (New Listener () {

...

});

}

}

The latter two adapters can be set by the project properties "Code Style". If you want to add more screens to this MIDP application, you can add more MIDP applications to your project with the displayable template, or add more MIDP applications to your project via MIDlet template.

After generating the application framework, you can add the required code according to Part 2 of this article, and compile (pre-authentication), package, simulate, and publish, JBuilder provides a built-in web server and FTP server using the convenient way of jbuilder. To facilitate the release of the developer test application. If you generate an Form type Displayable object using the MIDLET or Displayable Template, you can use the JBuilder's "MIDP Designer" to customize the user interface, that is, the UI element is generated from the component panel, and the location of these elements can be adjusted by the mouse or copy. , Delete, etc., this is the powerful function of JBuilder. If you use a template to generate a DisplayAble class, a jbinit () method is automatically generated. When you add a UI element in the Form, the designer adds the code into the jbinit () method. If you want to open an existing DisplayAble class to the designer, it already has a UI element, but there is no jbinit () method, first need to generate a jbinit () method, then transfer all UI elements into. [References] 1. Connected Limited Device Configuration Specification Version 1.0a, 2. J2ME CLDC API 1.03. Mobile Information Device Profile (JSR-37) JCP Specification4. Above Java Mobile Information Device Profile (MIDP) 1.0.3 Reference Implementation API Profile All from http://java.sun.com/J2ME

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

New Post(0)