×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Jan 2006
    Posts
    3

    java.lang.ClassNotFoundException

    Hey,

    I've been stumped with the following error the whole day and I've consulted and tried suggestions from many forums but to no avail. Below is the error and following that is my code.

    <ERROR MESSAGE>

    Unable to create MIDlet MsgMidlet
    java.lang.ClassNotFoundException: MsgMidlet
    at com.nokia.phone.sdk.concept.midlet.MIDletState.createMIDlet(+29)
    at com.nokia.phone.sdk.concept.jam.JAMMIDlet.run(+60)

    <CODE>

    package src;

    import java.io.IOException;
    import java.io.InputStream;
    import java.lang.*;
    import javax.microedition.io.*;
    import javax.microedition.lcdui.*;
    import javax.microedition.midlet.MIDlet;
    import javax.microedition.midlet.MIDletStateChangeException;

    // main midlet class
    public class MsgMidlet extends MIDlet implements CommandListener {
    // initialising all variables
    Form inputScreen;

    Alert confirmationAlert;

    Display display;

    TextField txtCellNum;

    TextField txtMessage;

    StringItem strProgress = null;

    Command cmdSend = new Command("Send", Command.ITEM, 8);

    Command cmdExit = new Command("Exit", Command.EXIT, 10);

    public MsgMidlet() {

    inputScreen = new Form("New Message");

    this.inputScreen.append(txtCellNum);
    this.inputScreen.append(txtMessage);

    // append command and set command listener
    this.inputScreen.addCommand(this.cmdSend);
    this.inputScreen.addCommand(this.cmdExit);
    this.inputScreen.setCommandListener(this);

    }

    protected void startApp() throws MIDletStateChangeException {

    if ( display == null)
    {
    display = Display.getDisplay(this);
    }

    display.setCurrent(inputScreen);

    }

    protected void pauseApp() {
    // ignore
    }

    protected void destroyApp(boolean unconditional)
    throws MIDletStateChangeException {
    // just quit
    }

    // handle command selection
    public void commandAction(Command cmd, Displayable screen) {
    if (screen == this.inputScreen) {
    if (cmd == this.cmdSend) {
    send();
    } else if (cmd == this.cmdExit) {
    quit();
    }
    }
    }

    // send info via http
    private void send() {
    HttpConnection hc = null;
    InputStream in = null;

    try {
    String baseURL = "http://www.sendmsg.org/sendMessage.do";
    String parameterURL = "?parameters=27833562424&msg=hello"
    String url = baseURL + parameterURL;

    // strProgress.setText("Connecting...");

    hc = (HttpConnection) Connector.open(url);
    hc.setRequestProperty("Connection", "close");
    in = hc.openInputStream();

    // strProgress.setText("Reading...");

    // Clean up.
    in.close();
    hc.close();

    } catch (IOException ioe) {

    } finally {
    try {
    if (in != null)
    in.close();
    if (hc != null)
    hc.close();
    } catch (IOException IOE) {
    }
    }
    }

    // destroy current application
    public void quit() {
    notifyDestroyed();
    }
    }

  2. #2
    Super Contributor
    Join Date
    Nov 2003
    Location
    Bangalore , India
    Posts
    4,429

    Re: java.lang.ClassNotFoundException

    In which Emulator/device have you tried?

    I have corrected this code ;
    Please try with this modified code

    Constructor:
    Code:
    public MsgMidlet() {
    
    inputScreen = new Form("New Message");
    txtCellNum=new TextField("","",25,TextField.ANY);
    txtMessage=new TextField("","",25,TextField.ANY);
    this.inputScreen.append(txtCellNum);
    this.inputScreen.append(txtMessage);
    
    // append command and set command listener
    this.inputScreen.addCommand(this.cmdSend);
    this.inputScreen.addCommand(this.cmdExit);
    this.inputScreen.setCommandListener(this);
    
    }
    and ";"

    in this line String parameterURL = "?parameters=27833562424&msg=hello";

    Hope this helps!

    Regards
    Gopal

  3. #3
    Super Contributor
    Join Date
    Mar 2003
    Location
    Israel
    Posts
    2,280

    Re: java.lang.ClassNotFoundException

    In the jad and manifest, does the MIDlet-1 entry look like this:
    Code:
    MIDlet-1: [MIDlet's name], [MIDlet's icon], MsgMidlet
    or like this:
    Code:
    MIDlet-1: [MIDlet's name], [MIDlet's icon], src.MsgMidlet
    ?

    Because the final entry in any MIDlet-n property needs to be the fully qualified name of the MIDlet subclass (including any packages it is in) and I suspect you forgot to include the src package there.

    shmoove

Similar Threads

  1. java.lang.ClassNotFoundException: calmid/MIDlet1,help please
    By imran712 in forum Mobile Java Networking & Messaging & Security
    Replies: 1
    Last Post: 2007-08-17, 19:51
  2. java.lang.ClassNotFoundException: com/symbian/midp/io/protocol/mms/Protocol
    By chihchun in forum Mobile Java Networking & Messaging & Security
    Replies: 1
    Last Post: 2005-07-01, 09:24

Posting Permissions

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