1. Welcome to PHCorner Forums. Take a moment to Sign up and gain unlimited access and extra privileges that guests are not entitled to, such as:

    All that and more! Registration is quick, simple and absolutely free. Join our community today!

Tutorial J2me / game programming codes - setting up development environment

Discussion in 'Mobile Modding Tools' started by Draft, Feb 2, 2013.

  1. Draft

    Draft Administrator Staff Member Administrator

    Installing the development tools

    Although you can setup your development environment in several ways, I find this process really easy because you dont need to configure anything. Just follow the instructions and you'll get yourself started with programming in no time.

    1. Download and install the J2SE SDK preferably version 1.4.2. You can download it Please or Register to view links
    2. Download and install Eclipse IDE (I think you only need to unzip the archive file). You can get it Please or Register to view links.

    3. Download and install Nokia Carbide.j. It contains tools you can use to emulate various nokia specific devices. You can download it Please or Register to view links.

    Now this is the fun part.. Testing if you have properly configured your development tools. :D

    Testing the installation

    1. To check that you have successfully incorporated carbide.j with eclipse, make sure that there are carbide icon on the upper right part of your window and a "carbide.j" option under the Tools menu exist. Take a look at the following images:

    Fig 1 - Carbide.j icons

    Fig 2 - Carbide.j menu item

    2. Create a new MIDP Project ( File > New > Project > Java > MIDP Project (Nokia SDK Plug-in). Just follow the follow the images:

    Fig 3 - Choose MIDP Project (Nokiad SDK Plugin).

    Fig 4 - Name your project.

    Fig 5 - Choose an emulator you want to use.

    Fig 6 - Disable the "Start with designer tool" option. We wont be using it here.

    Fig 7 - Click finish.

    2. Lets create a MIDlet. Create a class file and name it 'MyMidlet'. Just copy the following code:

    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.Display;

    public class MyMidlet extends MIDlet {

    private MyCanvas myCanvas;

    public MyMidlet() {
    myCanvas = new MyCanvas();

    protected void startApp() throws MIDletStateChangeException {

    protected void pauseApp() {

    protected void destroyApp(boolean u) throws MIDletStateChangeException {

    3. Lets create the canvas. Create a class file and name it 'MyCanvas'. Just copy the following code:

    import javax.microedition.lcdui.Graphics;
    import javax.microedition.lcdui.Canvas;

    public class MyCanvas extends Canvas {

    public MyCanvas() {

    public void paint(Graphics g ) {
    g.fillRect(0, 0, getWidth(), getHeight());
    g.drawString("Hello World of J2ME", 10, 10, Graphics.LEFT | Graphics.TOP);

    4. Run the application by clicking the "Run MIDlets on emulator" icon (see Fig 1). Note that you need to highlight the MyMidlet.java file on the package explorer so that the "Emulate" button is not disabled when you start your emulator. Take a look at the image below:

    Fig 9 - Running the emulator.

    A = The button you need to click to start the emulator.
    B = You need to highlight the MIDlet of your application so that the "Emulate" Button is not disabled.
    C = Click emulate to start the emulator.

    5. You'll see an output that looks like this one:

    Fig 9 -The output.

    Name: Please or Register to view links
    Location: Legazpi City, Philippines
    Please or Register to view links
    Anya0711, cyberkram, KHYVEZ and 3 others like this.
  2. richardrr

    richardrr Forum Expert Established

    bm for
    future use,,
    thanks mam..
  3. salamat dito boss Draft (y)
  4. Causing Glenn

    Causing Glenn daemonX Staff Member Moderator

    ...mpag-aralan nga to
    interested about j2me...
    EviNadz likes this.
  5. La Freak

    La Freak Support Team Staff Member Support Team

    tnx Draft That was wicked!!!:hilarious:
  6. any code for main class? Gusto ko kasing gumawa ng java game eh, saka code para sa Drop Down List.

    YOVICPAW Addict Established

    Makakagawa din dto para sa Android oh java phone lag?

Share This Page