×

Discussion Board

Results 1 to 3 of 3

Hybrid View

  1. #1
    Registered User
    Join Date
    Dec 2012
    Location
    Mumbai, Maharashtra, India
    Posts
    79

    Problem in Midletsuite.....

    I am beginner in J2ME.... While learning Midlet suite from tutorial link - http://www.j2mesalsa.com/elearning/MIDP.html... I downloaded three programs from that link which are as follows....

    FirstMIDlet.java :-
    package com.j2me.salsa.midletsuite;
    import javax.microedition.lcdui.Display;
    import javax.microedition.midlet.MIDlet;

    public class FirstMIDlet extends MIDlet
    {
    public FirstMIDlet() {

    HelloWorldForm helloForm = new HelloWorldForm("Hello World From Midlet 1", this);
    Display.getDisplay(this).setCurrent(helloForm);
    }
    protected void startApp() {}
    protected void pauseApp() {}
    protected void destroyApp(boolean bool) {}
    }

    SecondMIDlet.java :-
    package com.j2me.salsa.midletsuite;
    import javax.microedition.lcdui.Display;
    import javax.microedition.midlet.MIDlet;

    public class SecondMIDlet extends MIDlet
    {
    public SecondMIDlet() {

    HelloWorldForm helloForm = new HelloWorldForm("Hello World From Midlet 2", this);
    Display.getDisplay(this).setCurrent(helloForm);
    }
    protected void startApp() {}
    protected void pauseApp() {}
    protected void destroyApp(boolean bool) {}
    }

    ThirdMIDlet.java :-
    package com.j2me.salsa.midletsuite;
    import javax.microedition.lcdui.Display;
    import javax.microedition.midlet.MIDlet;

    public class ThirdMIDlet extends MIDlet
    {
    public ThirdMIDlet() {

    HelloWorldForm helloForm = new HelloWorldForm("Hello World From Midlet 3", this);
    Display.getDisplay(this).setCurrent(helloForm);
    }
    protected void startApp() {}
    protected void pauseApp() {}
    protected void destroyApp(boolean bool) {}
    }

    HelloWorldForm.java:-
    package com.j2me.salsa.midletsuite;
    import javax.microedition.lcdui.Command;
    import javax.microedition.lcdui.CommandListener;
    import javax.microedition.lcdui.Displayable;
    import javax.microedition.lcdui.Form;
    import javax.microedition.midlet.MIDlet;

    public class HelloWorldForm extends Form implements CommandListener
    {
    private Command exitCommand;
    MIDlet midlet;

    public HelloWorldForm(String greeting, MIDlet midlet)
    {
    super("MIDlet Suite");
    this.midlet = midlet;
    exitCommand = new Command("Exit", Command.EXIT, 1);
    this.append(greeting);
    this.addCommand(exitCommand);
    this.setCommandListener(this);
    }

    public void commandAction(Command cmd, Displayable disp) {
    if (cmd == exitCommand) {
    midlet.notifyDestroyed(); // Midlet notifies the AMS that it has done its work.
    }
    }
    }

    From the above stuff..... i have to access FirstMIDlet, SecondMIDlet, ThirdMIDlet from HelloWorldForm program & i want to done this by running HelloWorldForm program. According to me,Constructor of HelloWorldForm have to access that all three classes but this is giving me error which is as follows :-

    Unable to create MIDlet com.j2me.salsa.midletsuite.HelloWorldForm
    java.lang.IllegalAccessException
    at com.sun.midp.midlet.MIDletState.createMIDlet(+34)
    at com.sun.midp.midlet.Selector.run(+22)

    How should I resolve this problem?????

  2. #2
    Registered User
    Join Date
    Sep 2012
    Posts
    31

    Re: Problem in Midletsuite.....

    Quote Originally Posted by Rahul More View Post
    I am beginner in J2ME.... While learning Midlet suite from tutorial link - http://www.j2mesalsa.com/elearning/MIDP.html... I downloaded three programs from that link which are as follows....

    FirstMIDlet.java :-
    package com.j2me.salsa.midletsuite;
    import javax.microedition.lcdui.Display;
    import javax.microedition.midlet.MIDlet;

    public class FirstMIDlet extends MIDlet
    {
    public FirstMIDlet() {

    HelloWorldForm helloForm = new HelloWorldForm("Hello World From Midlet 1", this);
    Display.getDisplay(this).setCurrent(helloForm);
    }
    protected void startApp() {}
    protected void pauseApp() {}
    protected void destroyApp(boolean bool) {}
    }

    SecondMIDlet.java :-
    package com.j2me.salsa.midletsuite;
    import javax.microedition.lcdui.Display;
    import javax.microedition.midlet.MIDlet;

    public class SecondMIDlet extends MIDlet
    {
    public SecondMIDlet() {

    HelloWorldForm helloForm = new HelloWorldForm("Hello World From Midlet 2", this);
    Display.getDisplay(this).setCurrent(helloForm);
    }
    protected void startApp() {}
    protected void pauseApp() {}
    protected void destroyApp(boolean bool) {}
    }

    ThirdMIDlet.java :-
    package com.j2me.salsa.midletsuite;
    import javax.microedition.lcdui.Display;
    import javax.microedition.midlet.MIDlet;

    public class ThirdMIDlet extends MIDlet
    {
    public ThirdMIDlet() {

    HelloWorldForm helloForm = new HelloWorldForm("Hello World From Midlet 3", this);
    Display.getDisplay(this).setCurrent(helloForm);
    }
    protected void startApp() {}
    protected void pauseApp() {}
    protected void destroyApp(boolean bool) {}
    }

    HelloWorldForm.java:-
    package com.j2me.salsa.midletsuite;
    import javax.microedition.lcdui.Command;
    import javax.microedition.lcdui.CommandListener;
    import javax.microedition.lcdui.Displayable;
    import javax.microedition.lcdui.Form;
    import javax.microedition.midlet.MIDlet;

    public class HelloWorldForm extends Form implements CommandListener
    {
    private Command exitCommand;
    MIDlet midlet;

    public HelloWorldForm(String greeting, MIDlet midlet)
    {
    super("MIDlet Suite");
    this.midlet = midlet;
    exitCommand = new Command("Exit", Command.EXIT, 1);
    this.append(greeting);
    this.addCommand(exitCommand);
    this.setCommandListener(this);
    }

    public void commandAction(Command cmd, Displayable disp) {
    if (cmd == exitCommand) {
    midlet.notifyDestroyed(); // Midlet notifies the AMS that it has done its work.
    }
    }
    }

    From the above stuff..... i have to access FirstMIDlet, SecondMIDlet, ThirdMIDlet from HelloWorldForm program & i want to done this by running HelloWorldForm program. According to me,Constructor of HelloWorldForm have to access that all three classes but this is giving me error which is as follows :-

    Unable to create MIDlet com.j2me.salsa.midletsuite.HelloWorldForm
    java.lang.IllegalAccessException
    at com.sun.midp.midlet.MIDletState.createMIDlet(+34)
    at com.sun.midp.midlet.Selector.run(+22)

    How should I resolve this problem?????
    The example whatever being given in the link is for showing how a midlet suite can have many midlets in it , as a midlet itself cant display anything for each midlet the same form is being used as the ui . Here helloform is not a midlet , so if you try to run there wont be any result .
    In j2me the displayable(form) itself cant run anything .,like main in java -- > midlet is the starting point of execution so only he has called the form in the midlet. so try to run the application as -- >Emulated Java ME JAD . then you can see the three midlets in a list for execution . Hope this will resolve your problem
    Regards,
    Venkatesh

  3. #3
    Registered User
    Join Date
    Dec 2012
    Location
    Mumbai, Maharashtra, India
    Posts
    79

    Re: Problem in Midletsuite.....

    Ok.........Thanx to help me.......Thanx a lot Venkatesh.....

Similar Threads

  1. e71 - MIDletSuite problem
    By parag.rughani in forum Mobile Java General
    Replies: 3
    Last Post: 2009-03-20, 16:57
  2. Running MidletSuite on real Pocket PC
    By Aruna Gottimukkala in forum Mobile Java Tools & SDKs
    Replies: 1
    Last Post: 2008-01-03, 14:24
  3. Platform Request used for updating existing midletsuite?
    By hlothman in forum Mobile Java Networking & Messaging & Security
    Replies: 5
    Last Post: 2007-01-22, 20:41
  4. how to exchange information between the MIDlets in the same MIDletsuite
    By lakshmanraob in forum Mobile Java Networking & Messaging & Security
    Replies: 0
    Last Post: 2005-10-24, 15:38

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •