0% found this document useful (0 votes)
28 views

Lab One: A First Java Mobile Program (CLDC/MIDP)

Uploaded by

getchew
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views

Lab One: A First Java Mobile Program (CLDC/MIDP)

Uploaded by

getchew
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Mobile Programming Laboratory Manual 1 Addis Ababa University, Institute of Technology,

February 2015, - Prepared by Eyob Gebretisnae. Center of Information Technology & Scientific Computing

Lab One
A First Java Mobile Program (CLDC/MIDP)
Objective:

 To introduce students with Java ME

 To be familiar with Java ME IDE (Integrated Development Environment)

 Compiling and running a simple Text Message on Suns Mobile phone Emulator

 To write a program how to display Images on Mobile devises

Put Your Hand for Exercise

Task 1: Creating a Mobile program project

 Open Net beans IDE using, startAll ProgramsNetbeans


 Create a project using, Click Fileand Then Click New Project
 Form the coming dialog box select Java ME from Category and Mobile Application
from Project, then Click Next
 Write project Name Lab1 and Select Project Location, and you can select Both Check
box options, but for now Deselect Create Hello MIDlet Check Box then Click next
 Select latest version of CLDC and MIDP, then Click next
 Click next and then finish, and you will see this on the left side of the IDE

Task 2: Creating a Main Class that extends MIDlet class

 Right Click on Source Package then Click new and select MIDlet
Mobile Programming Laboratory Manual 1 Addis Ababa University, Institute of Technology,
February 2015, - Prepared by Eyob Gebretisnae. Center of Information Technology & Scientific Computing

 On the coming dialog box write the MIDlet name MidletLab, and click Finsh
 Then you will see the follwig code, and understand the life cycle of Java ME project

Task 3: Adding Additional Codes to MidletLab1 class

 Import the necessary packages for user interface.

import javax.microedition.lcdui.*;

 Create a form with a title our FirstMobApp

private Form form;

form=new Form("Our First App");

 Add this Welcome txt to the form


form.append("Hello World \n Enjoy it!");
 Create a display and set the current display the form your create previously

Display d = Display.getDisplay(this); d.setCurrent(form);

 Compile and Run the application


Mobile Programming Laboratory Manual 1 Addis Ababa University, Institute of Technology,
February 2015, - Prepared by Eyob Gebretisnae. Center of Information Technology & Scientific Computing

Task 4: Adding images to the First Mobile application program

 Create two image objects

private Image img,img1;

try{

img=Image.createImage("/test.jpg");

img1=Image.createImage("/watermark.jpg");

} catch(Exception e){

 Append the images to the previous form you created.

form.append(img);

form.append(img1);

 Compile and run the application

You might also like