★ (transfer) J2ME learning notes (3)

xiaoxiao2021-03-06  17

From today I think I will have a long period of time, I will not involve real actual development, this time is mainly concentrated in the foundation.

on. Oh, I won't go, how can I run it? However, it is mainly because I don't have to rush to my brother, so I want to study hard. Do not

Code is definitely written. After all, write more code to learn faster ^ _ ^

Oh, step by step and starting the journey of mobile phone. I don't know if I can insist on this piece, because the company's working pressure is also very

Big. Usually don't have a rest, there is still a bunch of things to do on the weekend. So is also a very bitter aspect. Ha ha. Try to do your best. One

It is not a way directly to Web, huh, huh, learn more about it. After all, handheld equipment is a development trend in the future.

When I learned, I used Sun's official MIDP instance. You can go down by yourself. I chose the reference source code for MIDP_2.0. Writing a MIDlet can perform on the actual device or simulator requires the following steps: 1. Write program code 2, compile 3, preverify this step is important because J2SE support installed on many class PCs, but The actual J2ME is not supported

hold. 4. Write the description of document 5, synthesis JAR file 6, test tired 7, run on the simulator or entity machine. OK

I will start writing a simple example, starting from the code to complete the final 7 steps. (This example is relying on with MIDP_2.

0 Some of the already defined interfaces are made, so I put this program on the MIDP root directory I decompressed: f: / midp. )

The first step, write code:

import javax.microedition.midlet *;. import javax.microedition.lcdui *;. public class HelloMIDlet extends MIDlet implements CommandListener {private Command exitCommand; private Display display; public HelloMIDlet () {display = Display.getDisplay (this); exitCommand = New Command ("exit", command.screen, 2);} public void startapp () {TextBox T = New TextBox ("Hello MIDLET", "Test String", 256, 0); t.addcommand; t .setCommandListener (this); display.setCurrent (t);} public void pauseApp () {} public void destroyApp (boolean unconditional) {} public void commandAction (Command c, Displayable s) {if (c == exitCommand) {destroyApp (false); notifydestroyed ();}}}

Step 2: Compile me to build a midjavac.bat file under F: / MIDP specifically used to compile

Javac -g: none -classpath f: / midp / classes ;. -bootclasspath f: / midp / classes% 1

-bootclasspath This parameter I also use it, it should be that the control compiled time control is only used under the base class in the formulated directory. Such as

If you don't use this parameter, it is possible that the program you write can run on the PC, but you cannot run on the handheld device that supports the MIDP.

Then go to the DOS to F: / MIDP and run Midjavac Hellomidlet Step 3: Pre-review, I have established the midver.bat file under F: / MIDP to perform pre-audit.

F: / midp / bin / preverify -classpath f: / midp / classes ;. -d% 1% 2

Go to the MIDP folder under DOS, run the Midver test hellomidlet If the pre-audible will create a folder TEST under F: / MIDP, the pre-audible is placed in it.

At this time, the program we wrote can be run on the simulator.

Step 4: Write the description document file name: Hellomidlet.jarmidlet-name: helloworldmidlet-version: 1.0.0midlet-vendor: Sun Microsystems, Inc.midlet-description: sample hello world midletmidlet-info-url: http: // java . Sun.com / J2ME / MIDLET-JAR-URL: http://127.0.0.1/hellomidlet.jarmidlet-jar-size: 1020microedition-profile: MIDP-1.0MicRoEdition-Configuration: CLDC-1.0Midlet-1: HelloWorld, Hellomidlet

Step 5: Synthetic JAR files to prepare a midjar.bat file JAR-CFM% 1% 2 -c ./%3. Run: Midjar Hellomidlet.jar Hellomidlet.jad Hellomidlet

Step 6: Testing troubleshooting a midjartest.bat file f: / midp / bin / midp -classpath f: / midp / classes;% 1 -Descriptor% 2

Run under DOS: Midjartest Hellomidlet.jar Hellomidlet.jad huh, you should see the running situation? ! If you find alert: error verifying class hellomidlet, this is that your program has not pre-audible ^ _ ^

Step 7: Oh, if you have a handheld device, try it to see it. If not there is only to run on the emulator. . correct

If you run the words on the simulator, you should not use JAR files.

Oh, in fact, these things are found, I can completely install a NOKIA or MOTO simulator, then use only on JB on Mobiles.

ET, then draw a plugin to get it. The reason why I have to use such complex (Khan ING .. is a bit impatient when you write)

The steps to complete such a simple step is true to better understand the completion of the mobile phone program.

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

New Post(0)