My J2ME learning course 3

zhaozj2021-02-16  113

I saw the concept knowledge about J2ME and WTK in the first two days. I have a general rational understanding. Today, I should write a HelloWorld or Foo program to make myself a bit sense of met, huh, huh, the computer is inseparable. .

Our Hand's It is WTK1.0 version, I downloaded Sun's WTK2.1, and on the Sun website, the latest 2.2beta has been released, the specific information will be studied tomorrow. .

After installed WTK2.1, you know this version of things and 1.0 have been large, but the core thing is still not changed, but there are many cumbersome steps when developing. Let's first take a look at the specific development steps:

1. Write program source code

2. Compile

3. Pre-audited

4. Write a description

5. Synthetic JAR

6. Test tired

7. Download to the simulator or mobile phone PDA

Here, it may be strange that the third step is called preverify, which is nothing in J2SE. On J2SE's Java virtual machine, the audit mechanism of the class is responsible for rejecting the illegal class file. The same is true for the CLDC supported by JVM. However, the class audit is expensive and time, so the KVM designer decided to move most of the audit work from the device to the desktop environment before class compilation. This step is specified as a pre-audit command. This is one of the different places developed with J2SE.

In fact, we don't have to care too much, because this is okay in the development, usually if you use JBuild to develop tools to help you get it.

Another important thing is to write a description. The description gear is generally named * .jad, the format is as follows

Hellomidlet.jad

MIDlet-name: HelloWorld

MIDlet-Version:

1.0.0

MIDlet-vendor: Sun Microsystems, Inc.

MIDlet-description: Sample Hello World MIDLET

MIDlet-info-url: http://java.sun.com/j2me/

MIDlet-jar-url: http://127.0.0.1/hellomidlet.jar

MIDlet-jar-size: 1020

MicroEdition-Profile: MIDP-2.0

MicroEdition-Configuration: CLDC-1.0

MIDLET-1: HelloWorld, Hellomidle

He needs to describe the specific information about this MIDlet, such as name, version, developer, description, information URL, JAR package URL, JAR package size, MIDP version, configuration version, MIDlet name, etc.

The URL information of the JAR package is used when Over-the-air (OTA) is published, that is, the network releases your J2ME program to let users download and install by web pages.

MicroEdition-Profile: MIDP-2.0

MicroEdition-Configuration: CLDC-1.0

The MIDP in WTK2.1 is a 2.0 version, and CLDC is 1.0.

Finally, it is the name of MIDlet-1, you can use the Chinese name, but you should pay attention to the Chinese code to use Unicode, otherwise it is garbled.

In fact, in JBuilderx (JBX), he comes with WTK2.0, and when you debug compilation, you can use it yourself to write JAD description files, you can debug it, and consider the cumbersome steps.

OK, let's take a look at how JBX writes a HelloWorld. First, let me talk about the setting of WTK under JBX, JBX comes with a WTK2.0_01, and you can see it under Tools-Configure JDKs. If you want to use the latest WTK version, such as I am 2.1, just one on the left, Select the installed directory, such as C: / WTK21, he can automatically identify J2ME Wireless Toolkit 2.1.

Then, pay attention to the new project file to choose JDK for J2ME Wireless Toolkit 2.1, if it is still the previous Java Version

1.4.2

_01-b06 You can establish the MDILET program without a law.

Newly built an empty project file, then New a micro's mdip midlet is your first MIDlet phone program. You can directly click on the run.

The JB style is always separated from the interface, so you have a class that inherits Form, and the other class is MIDlet. In Form, we can develop our mobile programs using JB powerful interface design tools, and JB play JAR package is also easy to first. Workers must have a good thing.

Simple modification super (), New Command ("Leave", command.exit, 1), and output text in jbinit (), is our HelloWorld.

OK, you can start playing our imagination, come on that screen!

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

New Post(0)