Categories: Java | How To | IDE/SDK | Eclipse
This page was last modified 04:46, 31 January 2008.
Creating your first MIDlet using EclipseME
From Forum Nokia Wiki
These instructions assume you've installed Java ME development tools according to article Installing Java ME development tools for S60.
Contents |
Create a new project
- Start Eclipse, and go to the workbench. (If you are unaware of Eclipse concepts such as the "workbench", now is a good time to use the Help function to learn the basics.)
- Select the menu item File | New | Project.
- Expand node J2ME and select J2ME Midlet Suite. Press Next.
- Give the project name HelloWorld. You can also change the workspace location to be different from the default. Press Next.
- Select Sun Java(TM) Wireless Toolkit 2.5.2 for CLDC and DefaultColorPhone. (Selecting S60 3rd Edition FP2 SDK for MIDP and S60Device will cause running the MIDlet to fail, with an dialog displayed, saying that the Jar file could not be initialized because of a caught exception.) Press Next.
- In tab Source, check the checkbox Allow output folders for source folders, and accept the default.
- Press Finish.
Eclipse's package explorer should show a newly created project HelloWorld, which includes folders src and res, library J2ME library, and JAD file HelloWorld.jad.
Create a new MIDlet
- Select the menu item File | New | Other.
- Expand node J2ME and select J2ME Midlet. Press Next.
- A dialog with the title J2ME Midlet appears.
- The Source folder setting item should already be set to <your workspace location>/src.
- For the Package setting item, give the name com.example.helloworld.
- For the Name setting item, give the name HelloWorldMidlet.
- Press Finish.
You should now see a newly created file HelloWorldMidlet.java in Eclipse's editor window, with some skeleton code. Eclipse's package explorer should show that it has been created under HelloWorld/src/com.example.helloworld.
Write MIDlet code
Replace the code of HelloWorldMidlet.java with the code from article Hello World in Java ME.
Debug MIDlet code
- Set a breakpoint at the start of method startApp.
- In the Package Explorer, right-click on HelloWorldMidlet.java, select Debug As, and then Emulated J2ME Midlet.
- A dialog comes up asking if you want to switch to the Debug perspective. Press Yes.
- The phone emulator window should now be displayed. Eclipse should have switched to the Debug perspective, and in the editor window, the execution of the MIDlet should have stopped at the breakpoint you set.
- Resume execution. The emulator's screen should now display "Hello Hello World!"
Create a deployment package
- In the Package Explorer, right-click on project HelloWorld, and select J2ME | Create package or J2ME | Create Obfuscated Package.
- A directory HelloWorld/deployed should have been created, containing the files HelloWorld.jad and HelloWorld.jar.
See also
External links
- Eclipse documentation: Creating a new J2ME MIDlet Project
- Eclipse documentation: Create a new Midlet
| Related Discussions | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| carbide.j的模拟器的问题 | wkdwangjun | Other Programming Discussion 关于其他编程技术的讨论 | 1 | 2006-06-28 04:12 |
| Smart messaging on Midlet | nachoyague | Mobile Java General | 2 | 2003-09-29 13:40 |
| Getting started with Mobile Application Development | niceonedave | Mobile Java Tools & SDKs | 0 | 2008-01-19 11:53 |
| Problem in Obex file pushing | madhurahuja | Bluetooth Technology | 20 | 2008-06-13 07:18 |
| 'Applet' or 'SecureCard'? | gregorytaiwan | Near Field Communication | 6 | 2007-06-19 16:28 |
