J2ME STUDY

xiaoxiao2021-03-06  234

J2ME STUDY

2004-8-3

In order to find a job, the summer vacation time has been a preliminary understanding of J2ME. The basic knowledge of J2ME and some learning information links are summarized below. We are willing to share with Java enthusiasts.

J2ME Basic Knowledge:

1) What is J2ME?

When the Java platform has developed to Java 2, in order to adapt to the development of different levels of computer hardware, the Java platform has formed three main branches:

J2se: Java 2, Standard Edition is designed for desktops, mainly running on operating systems such as Linux, Solaris, or Microsoft Windows.

J2EE: Java 2, Enterprise Edition is a platform for distributed, multi-user, and enterprise application systems. It is based on J2SE, adds the function of processing server-side computing, used to develop e-commerce or enterprise web applications.

J2ME: Java 2, Micro Edition, and J2se are different, it is neither a software that cannot be considered. Quantitatively, J2ME is a general name of a series of technologies and specifications that are launched by small embedded or mobile devices such as PDA (Personal Digital Assistant), mobile phones. It borrows a part of the J2SE class library, uses fewer APIs, and its Java virtual machine (JVM) in J2ME is much smaller than J2SE's JVM.

figure 1

Following the basic principles of "for a single development system for a variety of different devices." J2ME first distinguishes generally to two of the embedded devices: one is a embedded device with limited computing function, and the power supply is also limited; the other PDA, mobile phone); the other is relatively better, and A relatively relatively sufficient embedded device in power supply (computers, refrigerator, TV set-top box). Because of these two types of embedded devices, Java introduced a concept called Configuration, and then defined the above operational function, limited electricity, limited to the CONNECTED LIMITED Device Configuration (CLDC) specification; The specification is specified as the Connected Device Configuration (CDC) specification. That is, J2ME first uses all of the embedded devices into two abstract types using the concept of Configuration.

A typical feature of the CDC application device has a 32-bit processor, more than 2MB storage container, can be powered.

A typical feature of the CLDC application device has a 16-bit or 32-bit processor, and the total memory of 160kb to 512 kb, which is typically powered, and in a certain type of network.

CDC and CLDC are merely a basic set of functions for the most common configuration in various devices. However, in practical applications, there are great differences before different devices. Therefore, on the basis of Configuration, we propose the concept of Profile. The content specified in Profile is a specification and API settled for a class. After the Profile, it really has a complete environment that can run J2ME applications.

Mobile Information Device PROFILE or MIDP is based on CLDC, which is the first set of PROFILE, providing complete J2ME runtime for applications running on devices such as mobile phones and login-level PDAs. surroundings.

MIDP is committed to solving problems such as user interface, persistent storage, networking, and application lifecycles.

MIDLET refers to applications written in APIs defined by MIDP and CLDC specification.

2) The new feature of MIDP 2.0 MIDP is the earliest, and the fastest has developed, and we only discuss the development of J2ME MIDP applications. In October 2002, JAVA Community Process, see http://www.jcp.org, launched MIDP2.0 specification, compared with MIDP1.0, which greatly enhanced user interface, multimedia and game function, Support for network connection functions, while the OTA application downloads are included in the specification, and the wireless information device provides end-to-to-end security mechanisms.

In order to support the processing of sounds (such as playing WAV files), an optional package ABB (Audio Building Block) is added to MIDP2.0. Previously, ABB included only in Mobile Media API (MMAPI), now incorporating it into the MIDP, and developers can do not depend on MMAPI. Of course, if MMAPI is used, more functions can be developed for mobile devices, such as playing video streams on the PDA.

Support for J2ME game development may be that developers and users are looking forward to a long time, the game API provided by MIDP2.0 enables the game itself to make more fully utilized equipment itself. Its emergence is undoubtedly simplified in the development of J2ME games, and also enables developers to more control the program's graphical processing performance.

In terms of communication, MIDP 1.0 only supports HTTP, and MIDP2.0 adds support for HTTPS, packets, socket communications, and serial communication. In addition, MIDP2.0 also supports server Push architecture so that your phone can receive alarms, messages or broadcasts from the server, and operate on the application on the phone.

Support OVER-THE-AIR (OTA) provisioning is an important new feature of MIDP2.0 that enables users to dynamically deploy and update applications on mobile devices. The new version of the MIDP specification specifies how to discover, install, update, and delete MIDlet kits on mobile devices; at the same time, the service provider that provides application downloads can also determine if the MIDlet kit can run on the app, and from Get information on installation, update, and delete on your device. The MIDP OTA Provisioning model provides a single, standard deployment MIDP application for mobile service providers. This model has been adopted by many leading mobile device manufacturers and service providers.

Since human beings enter the network era, network security is always a key issue. MIDP2.0 adds powerful "end-to-end" security models. On the one hand, MIDP2.0 supports HTTPS, encrypts the transmitted data; on the other hand, MIDP 2.0 uses different security mechanisms with MIDP 1.0, using security domains to ensure unauthorized MIDlet kits cannot be accessed Controlled data, applications, and other networks and device resources.

J2ME development tool

1) J2MEWTK (J2ME Wireless Toolkit J2ME Wireless Toolkit): Provided by Sun Company, the latest version is J2ME Wireless Toolkit 2.2 Beta version, which provides only the operating environment of the MIDlet project, does not include the development environment.

J2ME Wireless Toolkit 2.1 Download: http://java.sun.com/products/j2mewtoolkit/download-2_1.html

J2ME Wireless Toolkit2.2 Beta Download:

http://java.sun.com/products/j2mewtoolkit/download-2_2.html (Install J2MewTK needs to install J2SE SDK1.4.2 and above, you need to register an account first)

2) Sun Java Studio Mobility 6: It is a J2ME integrated development tool provided by Sun that uses this tool to easily develop and debug the MIDlet program.

Download: http://developrs.sun.com/prodtech/javatools/jsmobility/downloads/index.html

3) Borland JBuilder

Built this platform, we must need to install: JBuilder 7 or JBuilder 8, Borland's MobileSet 3.1.

4) Java Communith Edition integrated development environment: Forte

(I didn't find the download address of the tool)

I have learned J2ME mainly to use the tools provided by the first two Sun, and there are no other things.

If the developed MIDlet program needs to be associated with J2EE, you may also need to install J2SDKee1.3.1 or its higher, or Tomcat, WebLogic, Apache Web, etc. Server tools.

J2SDKEE1.3.1 Download: http://java.sun.com/j2ee/download.html

Tomcat download: http://jakarta.apache.org/site/binindex.cgi

J2ME programming:

1) The MIDlet program executed on the mobile device must be inherited in the MIDlet class, inheriting the user class of such a class is the main program, and other user classes can be called in the program. In Sun Java Studio Mobility 6, the following code is automatically generated when new MIDLET classes are newly built:

Import javax.microedition.midlet. *;

Import javax.microedition.lcdui. *;

Public class test extends MIDLET

{

Public void startapp () {}

Public void pauseapp () {}

Public void destroyApp (boolean unconditional) {}

}

3) The general MIDLET program also needs the corresponding button command operation, which is also required to inherit the CommandListener interface. After inheriting the interface, you must implement the public void commandion (Command C, DisplayAble S) method in the class. Here is a general general structure:

Public Class Testmidlet Extends Midlet ImmmandListener {

Private display mdisplay;

Private form mmainform;

Private stringItem mimentageit;

Private Command MexitCommand, MConnectCommand;

Public TestMidlet () {

Mmainform = New form ("HitmIdlet");

MMessageItem = New stringItem (NULL, "");

MexitCommand = New Command ("exit", command.exit, 0); mconnectCommand = new command ("connect", command.screen, 0);

Mmainform.Append (MMessageItem);

Mmainform.Addcommand (MexitCommand);

Mmainform.Addcommand (MconnectCommand);

Mmainform.SetCommandListener (this);

}

Public void startapp () {

Mdisplay = display.getdisplay (this);

Mdisplay.SetCurrent (mmainform);

}

Public void pauseapp () {}

Public void destroyApp (boolean unconditional) {}

Public void CommandAction (Command C, Displayable S) {

IF (c == MexitCommand)

NotifyDestroyed ();

Else if (c == mconnectCommand) {

.. .. .. ...

}

}

Display object refers to a mobile phone's display, the Form object is a displayed window, and the Command object is a command object.

The startApp () method is the entry of the program.

See example http://developss.sun.com/techtopics/mobility/midp/Articles/Tutorial2/

This instance implements the function of the MIDlet program and the servlet connection of the web server.

4) Game programming

MIDP 2.0 includes a game API, which greatly simplifies the writing of 2D games, located in a javax.microedition.lcdui.game package. This package includes 5 classes: Gamecanvas, Layer, LayerManager, Sprite, Tiledlayer, these 5 classes provide 2 important features:

The Gamecanvas class provides features that implement redraw screens and response inputs in a game cycle.

The Layer class makes it more efficient to create a complex picture.

Specific use methods can be found: http://developss.sun.com/techtopics/mobility/midp/articles/game/

5) Provide two ways to create threads in the above two instances, with regard to the use of threads, see its API, in the java.lang package.

6) Examples Java Smart Ticket Sample Application provides integration of J2EE and J2ME, complicated but also a large application direction. But it also requires strong J2EE knowledge. The instructions and source code of this example can be downloaded here: http://java.sun.com/boeprints/code/index.html

references

1) Sub-information provided by Sun Company: http://java.sun.com/j2me/index.jsp

2) The status quo and development of J2ME: http://dev.9cbs.net/develop/Article/18/18870.shtm

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

New Post(0)