Sun One Studio 4 Mobile Edition Developing MIDlet Getting Started

zhaozj2021-02-11  179

Sun One Studio 4 Mobile Edition Developing MIDlet Getting Started

Sun ONE Studio 4 Mobile Edition - Combined with Java 2 Platform, Micro Edition (J2ME) - provides a complete Mobile Information Device Profile (MIDP) development environment, including complete Java Platform Debugger Architecture (JPDA) for mobile devices Debugging the Universal Emulator Interface (UE) on the simulator. This article describes the features of the Mobile version and provides guidance for creating and debugging a simple MIDlet Suite.

By vaughn spurlin

Aawolf: This is the first translation of J2ME, because the relationship between the project has been translated for more than half a month, and finally completed the hottest day in the summer. In fact, the J2ME has been a long time, but it has not been able to start the time and entrance point. After downloading Sun One Studio, although it is slow, there is still its own unique. I have been nonsense, say so much, I recently launched Pocket PC 2003, I will translate some relevant information as soon as possible, I hope everyone can go to my column: http://www.9cbs.net/develop/author/netAuthor / aawolf /

Introduction

Installing Mobile Edition

Quick Tour of Mobile Edition's Features

CREANG AND TESTING A MIDLET

IMPORTING AN EXISTING MIDLET

Debugging a MIDlet

Introduction

Introduction

Sun One Studio 4, Mobile Edition encapsulates the basic module of creating wireless applications, and additional modules are used for specific J2ME development - create smaller applications for more target devices. The Advanced Modular System of the IDE can be easier to add a delete function and insert a third-party tool. The expansion module can be easily added to the Mobile version - no payment - you can download them from Sun ONE Studio Update Center (or NetBeans Update Center). The Mobile version provides basic tools for normal Java development, plus two modules that support J2ME.

J2ME WIRELESS MODULE - Supports Midp Development WITH TEMPLATES, A WIZARD, Emulation Integration, AND Connected Limited Device Configuration (CLDC) Compilation

J2ME Wireless Module - Supports MIDP Development, including Templates, Wizards, Integrated Simulator, and Connected Limited Device Configuration (CLDC)

J2ME Wireless Toolkit - The WTK Wrapped As a NetBeans Technology Module for Integration with Sun One Studio

J2ME Wireless Toolkit - WTK is packaged as a NetBeans technology module to Sun One Studio

Installing Mobile Edition

Install mobile version

The MOBILE version of JDK and system requirements are described below, and next is the download and installation introduction.

JDK Requirements

Installing Java 2 SDK is a prerequisite for installing the Mobile version because the IDE itself runs on Java 2's JVM. Java 2 Platform, Standard Edition (J2SE), Version 1.4.0 is highly recommended, but 1.3.1 is also working very well. The earlier J2SE version cannot be used to run IDE, but if you need to support the old version of Java code, you can be configured as an additional compiler. J2SE can be downloaded below: »http://java.sun.com/j2se/.

System Requirements

system requirement

Mobile Edition Release Notes provides detailed information on system requirements. The Mobile version requires at least 350 MHz Pentium II or 333 MHz SPARC ULTRA 10, 128M RAM and 100M effective hard disk space.

Although there is only a formal support platform (Solaris 8, Windows NT / 2K, And Redhat Linux 6.2 and 7.1) has passed a wide quality assurance test, and IDE can still run on most UNIX operating systems - including Mac OS / X. Mobile version and Community version, you can also run well on Windows 98 / ME.

Download

download

Sun One Studio 4, Mobile Edition can be downloaded below: »http://forte.sun.com/ffj/downloads.html.

Alternatively, you can also download and install Sun One Studio 4, Community Edition, then install the Mobile version module from Sun One Studio Update Center.

Installation Instructions

Installation Notes

Install Sun One Studio Mobile Edition Please follow the method of Getting Started Guide. The Mobile version is configured after the installation is complete. In fact, if you are more willing to install the Mobile version module on a Community or Enterprise version, do it according to the following method. (These introductions apply to the Community version feature to the Mobile version).

1. Open the IDE, select Tools> Update Center in the IDE's main menu to open the Update Center Wizard.

2. Select Radio Button "Check The Web for Available Updates and New Modules" and select Location "Forte for Java Update Center", then click Next (Java Update Center will be renamed Sun One Studio Update Center).

3. Enter your development resource username and password in your proper location, then click Next.

4. Select all Mobile version modules in "Available Updates and New Modules" and other modules you want to install. Click on the top button to select these modules in "include in install", then click Next (see Figure 1).

5. Once you agree to the license agreement, the module installation will be completed automatically.

Figure 1: Selecting Modules to install using the update center wizard.

Installing the J2ME Wireless Toolkit - Standalone Version installation J2ME Wireless Toolkit - Standalone Version

The J2ME Wireless Toolkit module included in Sun One Studio 4 Mobile Edition is J2ME Wireless Toolkit (J2MEWTK) 1.0.3. All Sun One Studio 4 Editions can also be configured to use a separate version of J2ME Wireless Toolkit as a replacement or new module.

The latest version of J2mewtk can be downloaded in the following URL: »http://java.sun.com/products/j2mewtoolkit.

Note: The installation process will ask you to install Integrated or Standalone version. Selecting the Standalone Options - ITEGRated options will try to install J2MEWTK to the existing Sun One Studio.

Note: These modules will include J2MewTK 1.0.3 compatible with Sun One Studio 3.0, but not supported Sun One Studio 4. It will also include some future J2MEWTK version addresses.

Emulator Installation

Simulator installation

Figure 2: Selecting An Emulator Installation Directory.

After Sun One Studio is installed, you should check if the J2MEWTK's simulator is properly installed. You will also use this process to install additional simulators, or if you use J2MEWTK as a separate product to install.

1. Start IDE and click on the Runtime Tab at the bottom of the Explorer window.

2. Open the following node Device Emulator Registry> Installed Emulators> J2ME Wireless Toolkit 1.0.3.

The J2MewTK simulator should be listed under the J2ME Wireless Toolkit node. If you want all simulators, you must ensure that they are installed correctly and skip the steps below.

In fact, in some configurations, version compatibility issues affect the J2mewtk simulator that is automatically installed, you need to manually install them. If you meet any of the following conditions, you need to complete the following steps.

Some or all J2MEWTK simulators are lost

J2ME Wireless Toolkit 1.0.3 Lost

You will install J2MewTK as a Standalone product

You need to install additional simulator

3. Right click on the Installed Emulators node and select Add Emulator from the context menu.

4. In the SELECT Emulator Installation Directory dialog, you want to select the path to the simulator you want to install.

TIP

On the Windows platform, for example, the default installation path of J2MEWTK is C: / J2mewtk .. If you use the Mobile Edition module (including J2meWTK), the path is the default path of the J2MEWTK component in the / Emulator. Forte module is C: / Forte4j / Emulator / J2MEWTK-1_0_3-win.

Quick Tour of Mobile Edition's Features

Now we will look at the full features of the Sun One Studio Mobile Edition IDE. This is to provide sufficient basic knowledge so you can understand the demonstration of creating MIDlets.

Startup

Start Mobile Edition IDE, edit Workspace is activated, the following three windows are opened: main window - consists of menus, toolbars, and Workspace Tabs for editing, running, debugging

Browse Window - Contains views such as selecting file systems, engineering, Javadoc, and Runtime (default open file view)

Properties Window - Displays the properties of the currently selected object in the browsing window.

Object-based views

Figure 3: Explorer Window, FileSystems View, Showing Objects and Properties Belonging to the UdeMo Example.

Each browse view shows a tree of an object node, each containing some sub-object nodes that can be opened. For example, the source code number is displayed in the top-level node in the file system view - represents the directory in the local file system, or the JAR file containing the directory structure. Open a superior node and display the included node, such as subdirectories, Java objects, or other files. For example, open a Java object node, display the Field node, the constructor node, the Method node, and the bean pattern node. Figure 3 is an object and attribute in an UIDEMO example.

Options and profies

The entire IDE contains an amazing number of user configuration properties through a huge interconnected object tree. IDE objects can be easily dynamically added, deleted, and operated.

For example, for the demonstration IDE structure, the following steps describe how to set the display extension in the Explorer window.

1. From the main menu, select Tools> Options to open the Options window.

2. Access to node, IDE Configuration> System

3. Click the System Settings node and pay attention to the attribute page that Options open.

4. Set show file extensions for True

Immediately, the extension of the file object appears in the Explorer window.

Code Samples

Sun One Studio 4, Mobile Edition with a set of categories of MIDLETS and MIDLET Suites examples, users can be used to do some development preparations. These examples are accessed directly in the FileSystem page of the Explorer window in the Sampler folder. The Sampledir folder is shown in Figure 2 and below the FileSystems node.

The Sampledir node contains different child nodes. The EXAMPLE and MIDP nodes contain MIDlet source code discussed by MIDLET Suites. The ICONS node contains imaged and icons. The four nodes of the bottom - needmo, Demos, Games, and Photoalbum - are MIDlet Suites, which can be run directly. Run these MIDlet Suites, right-click them, then select Execute in the context menu. IDE will build classes, and build into a JAR file, configure it in the default emulator and switch to Running Workspace and run the simulator. We can see that the MIDlet suite in the IDE is a very simple process, compiled, build, but the jar is automatically completed.

CREANG AND TESTING A MIDLET

The task here is about creating and testing a MIDLET.

»CREANG A PractICE PACKAGE

Create a packet for practice

The first task is to create a Java package for saving MIDlet Suite demo:

1. In your local environment, create (or select) a workspace for exercises - means that outside IDE. For example, you can create C: /Practice_J2ME.2 in a Windows environment. In the IDE browsing window, in the FileSystems view, right-click on the top layer FileSystems node, select Mount> local Directory from the context menu.

3. Choose your practice workspace (Step # 1) via new wizard, then click Finish.

The working space you choose will appear immediately in FileSystem.

4. Right click on the Configured contact workspace, select New> Java Package from the context menu.

5. New Wizard will prompt the name of the new Java package, name this demo, then select Finish

»CREANG MIDLET Suite with an inTIAL MIDLET

Figure 4: using the new wizard to create a midletsuite.

The following tasks are to create a new MIDlet Suite from the template of Sun One Studio, with an option to create a separate MIDlet, and may have another MIDlets in the future. 1. In the browsing window, right-click on the DEMO package created above, select New> MIDP> MIDLETSUITE.2 from the context menu. In New Wizard, name the new MIDlet Suite to Demosuite, then click Next3. New Wizard Next Interface (see Figure 4), select the "CREATE New MIDlet" option. Select Hellomidlet template, name new MIDlet as demohello, then click Finish. Or, you can also choose Next to add an icon, or just explore the steps behind New Wizard. 4. Open the demohello midlet in the Source Editor and locate the startApp () method (probably in the middle of the code). Change "Test String" into your favorite greetings - For example, "G'day, Mate!" If you like Australia. See Figure 65. Right click on any location of the code and select Compile in the context menu. 6. Right-click Demosuite in the Explorer window and select Update Jar from the context menu. This command must be executed after you have not modified JAR content. 7. Right click on Demosuite again, select Execute from the context menu. The default simulator will be started, and the demohello midlet will be run. 8. Download Demohello MIDlet, check your greetings. Then turn off the simulator and return to the editing space. The image of the simulator is similar to Figure 5, except that the System ProPs MIDET is not added. »Adding an existing midlet to a MIDlet Suite Add an existing MIDlet to a MIDlet Suite Multiple MIDlets may be added to a MIDlet Suite that can fit the target device. 1. In the Explorer window, right-click the Demosuite node and select Edit Suite in the context menu. The Edit Suite special editor will be opened and include the MIDlets and Jar Contents tabs. In the MIDlets tag, you can add, delete, rearrange the MIDlets in Suite. In the Jar Contents tab, you can add or remove other resources in the MIDlet Suite's JAR. 2. Select the MIDlets tab and click the Add button. A new default value will be added to the list of MIDlets. Figure 5: Running the default emulator.

3. Define the properties of the new row according to the following explanation, then click OK. MIDlet Name - User See the name in the MIDlet Suite menu, changed to "System Props". MIDlet Class - Added to the existing MIDlet in Suite, browse through the Sampledir> Example Node, and select Propexample. Note: This is just just Add a reference -compiled and preverified class files in the menu must be added to the MIDET. Icon - Displays the icon after the MIDlet name in the menu. It can be ignored here. 4. Now select the JAR Contents tab, browse the sampledir> Example node again, select ProPexample and click Add. MIDlet will be added to the Selected Content Pane. 5. Click OK to close the Edit Suite window. 6. Right click on the Demosuite node again and select Update Jar from the context menu (remember to update after each modifying JAR) 7. Right click on the Demosuite node again and select Execute in the context menu. The default simulator will be started again. Check menu, see if Demohello and ProPexample are run correctly (see Figure 5). Importing an existing midlet is imported into a pre-existing MIDletsun One Studio to perform the Java code that is completed elsewhere is very good. In order to use the existing Java code, you can simply copy the code into a pre-existing FileSystem, or set the directory containing the code. In fact, there is a defect when introducing MIDlets. The default compiler specifies that the Java code is External CompiLation, although MIDlets must be specified as preverify compiler. Moreover, if you use the wrong compiler, the MIDlet will not compile errors, but an error is reported in the simulator because the preveri process is omitted. Use the following steps to ensure that the imported MIDlet is correctly compiled, executed, and debug, or set correctly, if necessary. This example uses a MIDlet under Sampledir, replacing a newly introduced MIDlet. All objects in SampleDir have been set correctly, so this example will demonstrate how to verify correct settings, replace demonstrations and modify errors. 1. In Explorer, select the Sampledir> Example node, right-click Propexample, select Properties from the context menu, and click the Execution tab. 2. Click the compiler attribute value to make the available compiler list visible. Note that debugger also needs to be set to Emulator Debugger, and Executor is set to Emulator Executor. The default settings for introduction code are also wrong, and they need to be corrected. Debugging a Midletsun One Studio debugger is all using JPDA. There are several different debugger type buildings to support different technologies, such as Emulator Debugger, Applet Debugger, and J2EE Server Debugger.

MIDLETS requires Emulator Debugger.Setting Breakpoints to set up a breakpoint, we only set a breakpoint in the demohello midlet: 1. Double-click Demohello in the Explorer window to open the code editor. 2. Place the cursor to the first line in the StartApp () method: TextBox T = New TEXTBOX ("Hello MIDlet", "G'day, Mate!", 256, 0); 3. Open the Debug menu in the IDE main form. The quick way to establish a breakpoint at this line is to select the Toggle BreakPoint menu item. But this time we choose Add Breakpoint to open the Add BreakPoint dialog. 4. Open the BreakPoint Type list in the Add BreakPoint dialog. We can see,  Line - breakpoint type, blocks when executed to the specified row.  Method - Interrupt when performing a specified event.  Exception - Interrupt when the specified exception is thrown.  Variable - Interrupt when the specified value is accessed.  Thread - Interrupt at the beginning or end of the thread.  Class - Interrupt when the specified class is loaded or unloaded. Figure 6: Setting a Breakpoint.

5. Select Line as an interrupt type, then click OK. Note that you can specify conditions before interrupting to achieve satisfactory results. In fact, this exceeds the scope of our current discussion. Once the breakpoint is set, this line is highlighted with pink, see Figure 6. Running the debugger runs the debugger All preparations are ready, how to run Debugger: 1 below. Select Demosuite in the Explorer window. 2. Select Debug> Start. IDE from the main menu of the IDE will be converted to Debugging Workspace and start the simulator. The Debugger window will appear in View Panels, you can open or close with the buttons at the top of the window. SESSIONS - Monitor multiple DEBUGGING sessions.breakpoints - breakpoints that occur simultaneously. Threads - Monitor the plurality of simultaneous execution threads. Call Stack - Tracking information of dynamic stacks. Watches - View variables of variables during execution. Variables - Check or set a variable value. Classes - Check that the class is available during the execution process. 3. Right-click the breakpoint that is set in the breakpoints view panel, then select Go to Source from the context menu. The Source Editor window will open the breakpoint line in the class being debugged. 4. Execute Demohello in the simulator. If you perform somewhere in KVM (Sun's K Virtual Machine), select Debug> Continue from the IDE main menu. Execution will be aborted when executed to the set breakpoint. You can check the call stack at this point, modify the variable value, or activate some other debugging. See Figure 7 in the DEBUGER window.

Figure 7: The Debugger window.

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

New Post(0)