ICA-INFO: Creating MyHelloWorld from MyFirstMidlet
Using the CASE method, create a HelloWorld program that may be run on a cell phone. The HelloWorld program should display, "Hello World from [your name]!!" The stages are:
I Make sure the J2ME library files are installed in BlueJ.
II Code and compile your file.
III Preverify your compiled file.
IV Create a manifest.mf file.
V Create a .jar file.
VI Create a .jsd file
VII Run the midlet.
Step 1) Before compiling your Java program, copy these two Jave 2 Micro-Edition library files files:
clcdapi10.jar
midpapi20.jar
from the R drive in the J2ME Libraries file to the C:\BlueJ\lib\userlib\ subdirectory. In BlueJ, add these two files to your library. Click Tools --> Preferences. Choose the Libraries tab. Click the Add button. Navigate to the C:\BlueJ\lib\userlib\ folder, and add each of the two jar files above.
Step 2) Create a new project inBlueJ called MyHelloWorldMidlet.
Step 3) In BlueJ or JCreator, create a new class called MyHelloWorld.
Step 4) Open the MyFirstMidlet.java program in BlueJ Copy all of the source code from MyFirstMidlet.java into your new MyHelloWorld class in BlueJ.
Step 5) In BlueJ, change every occurrence of MyFirstMidlet to MyHelloWorld.
Step 6) In BlueJ, add your name to this line:
StringItem item = new StringItem("Hello World!", "This is a Java ME MIDlet");
Make it say "Hello World from [your name]!!" plus "This is [your name]'s MIDlet"
Example: Hello World from Debbie and This is Debbie's midlet.
Step 7) Compile the program.
Step 8) Now, preverify your compiled MyHelloWorld.class program file. Run cmd. Then cd to
to your BlueJ project subdirectory. Execute the preverify command:
\Motorola RazrV3 SDK\JMESDK\bin\preverify -classpath "\Motorola RazrV3 SDK\JMESDK\stubs\jsr139.jar";"\Motorola RazrV3 SDK\JMESDK\stubs\jsr118.jar";. -d . MyHelloWorld
If your program passes the preverify, then go onto Step 8.
Step 9) Make a manifest.mf file by opening Notepad and copying the following lines into it:
MIDlet-Name: Hello World Example
MIDlet-Version: 1.0
MIDlet-Vendor: Motorola
MIDlet-1: MyFirstMidlet, , MyFirstMidlet
MicroEdition-Profile: MIDP-2.0
MicroEdition-Configuration: CLDC-1.0
Change the MIDlet-Vendor: Motorola line. Replace the word Motorola with a business name of your choice, for example, Debbie's Java Programming Company.
Change the MIDlet-1: MyFirstMidlet, , MyFirstMidlet line. Replace every occurrence of MyFirstMidlet to MyHelloWorld.
Save the file.
Step 10) Make a jar file. In BlueJ, go to Project --> Create JAR File. The .jar file will include your MyHelloWorld.class and manifest.mf file. You should now have a MyHelloWorld.jar file.
Step 11) Make a MyHelloWorld.jad file by opening Notepad and copying the following lines into it:
MIDlet-Name: Hello World Example
MIDlet-Version: 1.0
MIDlet-Vendor: Motorola
MIDlet-Jar-URL: MyHelloWorld.jar
MIDlet-Jar-Size: 1128
MIDlet-1: MyHelloWorld, , MyHelloWorld
MicroEdition-Profile: MIDP-2.0
MicroEdition-Configuration: CLDC-1.0
Change the MIDlet-Vendor: Motorola line. Replace the word Motorola with a business name of your choice, for example, Debbie's Java Programming Company.
Change the MIDlet-1: MyFirstMidlet, , MyFirstMidlet line. Replace every occurrence of MyFirstMidlet to MyHelloWorld.
Change the MIDlet-Jar-Size: 1128 line to reflect the size of your MyHelloWorld.class file. Find the size by looking up the file properties in My Computer. Find the file in My Computer, and right click on the file icon. The file size will be displayed in bytes. Substitute the number of bytes for your MyHelloWorld.class file for the 1128.
Save the file.
Step 12) Run the program in the Motorola SDK emulator.
0 Comments:
Post a Comment
<< Home