Javax.microedition.lcdui   &   javax.microedition.midlet.MIDlet

When I import the following statements i got an error that the library does not exist (either in eclips or netbeans):
import javax.microedition.lcdui.*;
import javax.microedition.midlet.MIDlet;
I have installed the "Wireless Toolkit 2.5.2", but the problem is still exist.
Any advice what should do??
Thanks you in advance.

Post in the correct forum. Either an Eclipse or NetBeans forum (most probably where you should post) or in one of the Java Mobility forums here:
http://forum.java.sun.com/category.jspa?categoryID=22

Similar Messages

  • Package javax.microedition.midlet does not exist

    Hi:
    I am trying to run the Currency Converter MIDlet. I am using SUnONE4. I have got all the updates for the SUN ONE. When I compile the Converter directory.. i get the following errors.. which indicate that it can't find the javax.micoredition..packages.
    converter/ConverterMIDlet.java [11:1] package javax.microedition.midlet does not exist
    import javax.microedition.midlet.*;
    ^
    converter/ConverterMIDlet.java [12:1] package javax.microedition.lcdui does not exist
    import javax.microedition.lcdui.*;
    ^
    converter/ConverterMIDlet.java [13:1] package javax.microedition.rms does not exist
    import javax.microedition.rms.*;
    I havem't downloaded the J2ME since i presume that i don't need it since i have updated SunONe. There inside the SUNone i can see under the Device Emulator registory the J2ME wireless toolkit.
    Can anyon ehelp please.

    make sure you have the microedition classes are in your classpath
    --Senthil                                                                                                                                                                                   

  • Javax.microedition.lcdui.TextField.setChars exception

    Hi
    I am developing an application for Mobile Banking for my College Project the program need to send an SMS with the Name and PIN no. I am using Sun WTK 2.3 the program compiles and preverifies correctly but when the Submit button is pressed an Illegal exception is thrown.
    java.lang.IllegalArgumentException
         at javax.microedition.lcdui.TextField.setChars(+105)
         at javax.microedition.lcdui.TextField.setString(+27)
         at CheckBal.commandAction(+157)
         at javax.microedition.lcdui.Display$DisplayAccessor.commandAction(+282)
         at javax.microedition.lcdui.Display$DisplayManagerImpl.commandAction(+10)
         at com.sun.midp.lcdui.DefaultEventHandler.commandEvent(+68)
         at com.sun.midp.lcdui.AutomatedEventHandler.commandEvent(+47)
         at com.sun.midp.lcdui.DefaultEventHandler$QueuedEventHandler.run(+250)
    This is the code.....
    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;
    import java.io.IOException.*;
    import javax.microedition.io.*;
    import javax.wireless.messaging.*;
    public class CheckBal extends MIDlet implements CommandListener
    private Form form;
    private Command exit;
    private Command submit;
    private Display display;
    TextField t1;
    TextField t2;
    public CheckBal()
    display = Display.getDisplay(this);
    exit = new Command("Exit", Command.EXIT, 1);
    submit = new Command("Submit", Command.OK, 1);
    form = new Form("Check Balance");
    public void startApp()
    t1 = new TextField("First Name:", "",30, TextField.ANY);
    t2 = new TextField("Enter PIN:", "",4, TextField.ANY);
    form.addCommand(exit);
    form.addCommand(submit);
    form.append(t1);
    form.append(t2);
    form.setCommandListener(this);
    display.setCurrent(form);
    public void pauseApp()
    public void destroyApp(boolean unconditional)
    public void commandAction(Command command, Displayable displayable)
    if (command == exit)
    destroyApp(false);
    notifyDestroyed();
    if (command == submit)
    try{
    try{
    String s1 = t1.getString();
         String s2 = t2.getString();
         String s3 = s1+s2;
    MessageConnection conn = (MessageConnection)Connector.open("sms://:+919412130071");
         TextMessage msg = (TextMessage)conn.newMessage(MessageConnection.TEXT_MESSAGE);
         msg.setPayloadText(s3+ " Balance");
         conn.send(msg);
    } catch(Exception e) {
    t1.setString(e.toString());
         e.printStackTrace();
    catch(Exception ee) {
    t2.setString(ee.toString());
    catch(Error ee) {
    t2.setString(ee.toString());
    }

    Once again: you might want to look at some examples that are already out there.
    The IllegalArgumentException is throws in the midlet, judging by the stacktrace, so saying it orriginates from the servlet is not possible.
    Please do some more debugging. Check what you are sending, getting back and print some stuff in logs...
    Make sure the servlet works first: test it simply in your webbrowser, then try to get the midlet working.
    One tip: never count on length beeing more than -1, so simply do not use it!
    InputStream in = ...
    ByteArrayOutputStream bout = new ByteArrayOutputStream();
    byte[] buffer = new byte[512];
    int bs;
    while((bs = in.read(buffer)!=-1){
       bout.write(buffer,0,bs);
    String response = bout.toString();Much faster and works always.

  • Package javax.microedition.lcdui does not exist

    Hi, I'm new to J2ME.
    I have installed J2SE6.0 and Wireless Toolkit 2.5.
    When I run "javac HelloWorld.java" at command line,
    ouput =
    "HelloWorld.java:4: package javax.microedition.midlet does not exist".
    How to solve this simple problem?
    I'm using WindowsXP, is it required to set any CLASSPATH? Where can I find the J2ME library?
    Thank you very much!!!

    zaec
    Welcome to the forum. Please refrain from posting in old threads that are long dead. When you have a question, please start a topic of your own. Feel free to provide a link to an old thread if relevant.
    Also, please do not solicit off-forum email communication. I'm blocking your post on that account.
    db

  • Getting error javax.microedition.rms.RecordStoreException

    Hello ..
    I am create records in RMS .. and some time i am getting error like ..
    javax.microedition.rms.RecordStoreException: error finding first fit block
    at javax.microedition.rms.RecordStore.allocateNewRecordStorage(+76)
    at javax.microedition.rms.RecordStore.addRecord(+65)
    i dont knw why this error is coming and it comes some time not always .. any idea what is the problem with that .. ??

    i just added ur code to simple midlet, its working fine.
    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;
    import javax.microedition.rms.*;
    public class Test extends MIDlet
         public Display display;
         public Test()
         try
         display = Display.getDisplay(this);
         catch(Exception e)
         Form form;
         public void startApp()
         form = new Form("Test");
         display.setCurrent(form);
         Store();
         retive();
         RecordStore _rs;
         public void Store()
         try
         byte[] data = "abcd".getBytes();
         if(_rs==null)
         _rs = RecordStore.openRecordStore("x", true);
         _rs.addRecord(data, 0, data.length);
         catch(Exception e)
         System.out.println("e "+e.toString());
         public void retive()
         try
         String temp =new String(_rs.getRecord(1));
         form.append(temp);
         }catch(Exception e)
         public void pauseApp()
         public void destroyApp(boolean unconditional)
    }

  • Downloaded Java ME SDK 3.0 but mising lcdui and midlet packages

    Hi,
    I have just started looking into J2ME and have downloaded and installed the SDK 3.0. i have tried also to setup a sample application from the Java site which requires imports of..
    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;but when compiling it says the packages do not exist. I have searched the source code and they are not there, do i need to install anything else to get these to work?
    Thanks in advance
    Graham

    Note: This thread was originally posted in the [CLDC and MIDP|http://forums.sun.com/forum.jspa?forumID=76] forum, but moved to this forum for closer topic alignment.

  • Midlet gets null values from servlet

    hey,
    based on one of the source code examples on the java.sun.com website i made a midlet/servlet application. the midlet is sending a product id to the servlet, the servlet queries the database and shows the productinformation, the midlet reads the servlet output and displays it on his midlet form
    when i invoke the servlet in my browser: http://localhost:8080/Magazijn/query?product=1 then everything works fine (i see: Product Name : Deur). when the midlet is invoking the servlet i see Product Name : null
    after hours of searching the only thing i could come up with is that the servlet isn't passing the string retrieved from the resultset to the midlet
    the strange thing is that when i papss a normal string, for instance:
    String test = "test";
    out.println(test);
    that he shows this correct both in my browser and midlet
    when i do this:
    prodName = resutl.getString("name");
    out.println(prodName);
    i see "Deur" in my browser, but i see "null" in my midlet
    anyone can help me?
    here's the servlet source:
    import java.io.*;
    import java.sql.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.util.Date;
    public class Magazijn extends HttpServlet {
    public void doGet(HttpServletRequest request,
              HttpServletResponse response)
                        throws IOException, ServletException {
              doPost(request,response);
    public void doPost(HttpServletRequest request,
              HttpServletResponse response)
                        throws IOException, ServletException {
         String url="jdbc:mysql://localhost/test?user=root&password=root";
         Connection con = null;
         Statement stmt;
         ResultSet rs;
         String query;
         int prodId;
         String prodNaam;
         String prodPlaats;
         String prodAantal;
         response.setContentType("text/plain");
         PrintWriter out = response.getWriter();
         BufferedReader br = request.getReader();
         String buf = br.readLine();
         try {
                   //laden van de mysql driver
                   Class.forName("com.mysql.jdbc.Driver");
                   //maken van connectie met database
                   con = DriverManager.getConnection (url, "root", "root");     
                   //aanmaken van statement object
                   stmt = con.createStatement();
                   //nakijken welke naam we zoeken van product
                   String prod = request.getParameter("product");
                   //uitvoeren van query en die opvangen in een resultset
                   query = "SELECT * from onderdelen where id="+prod;
                   ResultSet result = stmt.executeQuery(query);
                   result.next();
                   prodId = result.getInt("id");
                   prodNaam = result.getString("naam");
                   prodPlaats = result.getString("plaats");
                   prodAantal = result.getString("aantal");
              out.println(new Date());
              out.println("");
                   out.println("Product ID: "+prodId);
                   out.println("Productnaam: "+prodNaam);
                   out.println("Plaats: "+prodPlaats);
                   out.println("Aantal: "+prodAantal);
              catch(ClassNotFoundException e) {
                   out.println("Could not load database driver: " + e.getMessage());
              catch(SQLException e) {
                   out.println("SQLException caught: " + e.getMessage());
              finally {
                   //sluiten database connectie
                   try {
                        if (con != null) con.close();
                   catch (SQLException e) {}
    here's the midlet source:
    import javax.microedition.rms.*;
    import javax.microedition.lcdui.*;
    import javax.microedition.midlet.*;
    import javax.microedition.io.*;
    import java.io.*;
    import java.util.Vector;
    public class MagazijnMidlet extends MIDlet implements CommandListener {
    Display display = null;
    List menu = null;
    TextBox input = null;
    String prodid = null;
    String url = "http://localhost:8080/Magazijn/query";
    static final Command backCommand = new Command("Terug", Command.BACK, 0);
    static final Command submitCommand = new Command("Verstuur", Command.OK, 2);
    static final Command exitCommand = new Command("Afsluiten", Command.STOP, 3);
    String currentMenu = null;
    public MagazijnMidlet() { }
    public void startApp() throws MIDletStateChangeException {
    display = Display.getDisplay(this);
    menu = new List("Maak uw keuze", Choice.IMPLICIT);
    menu.append("Opvragen product gegevens", null);
    menu.addCommand(exitCommand);
    menu.setCommandListener(this);
    mainMenu();
    public void pauseApp() { }
    public void destroyApp(boolean unconditional) {
    notifyDestroyed();
    void mainMenu() {
    display.setCurrent(menu);
    //Vraag om productnummer op te geven
    public void askProdid() {
    input = new TextBox("Geef Productnummer:","", 5, TextField.ANY);
    input.addCommand(submitCommand);
    input.addCommand(backCommand);
    input.setCommandListener(this);
    input.setString("");
    display.setCurrent(input);
    //Maken connectie midlet + verwerking
    void invokeServlet(String url) throws IOException {
    HttpConnection c = null;
    InputStream is = null;
    OutputStream os = null;
    StringBuffer b = new StringBuffer();
    TextBox t = null;
    try {
    c = (HttpConnection)Connector.open(url);
    c.setRequestMethod(HttpConnection.POST);
    c.setRequestProperty("IF-Modified-Since",
         "20 Jan 2001 16:19:14 GMT");
    c.setRequestProperty("User-Agent",
         "Profile/MIDP-1.0 Configuration/CLDC-1.0");
    c.setRequestProperty("Content-Language", "en-CA");
    // send request to the servlet.
    os = c.openOutputStream();
    String str = "product="+prodid;
    byte postmsg[] = str.getBytes();
    System.out.println("Length: "+str.getBytes());
    for(int i=0;i<postmsg.length;i++) {
    os.write(postmsg);
    // or you can easily do:
    //os.write(("product="+prodid).getBytes());
    os.flush();
    // receive response and display it in a textbox.
    is = c.openInputStream();
    int ch;
    while((ch = is.read()) != -1) {
    b.append((char) ch);
    System.out.print((char)ch);
    Form formProdGeg = new Form ("Gegevens product");
    StringItem infoItem = new StringItem("",b.toString());
    formProdGeg.append (infoItem);
    formProdGeg.addCommand (backCommand);
    formProdGeg.setCommandListener (this);
    display.setCurrent (formProdGeg);
    } finally {
    if(is!= null) {
    is.close();
    if(os != null) {
    os.close();
    if(c != null) {
    c.close();
    display.setCurrent(t);
    // event handler
    public void commandAction(Command c, Displayable d) {
    String label = c.getLabel();
    if(label.equals("Afsluiten")) {
    destroyApp(true);
    } else if (label.equals("Terug")) {
    mainMenu();
    } else if (label.equals("Verstuur")) {
    prodid = input.getString();
    try {
    invokeServlet(url);
    }catch(IOException e) {}
    } else {
    askProdid();
    tia
    lee

    Hi,
    first for some efficeincy, in your place your connection to the database in the init() method so you can have on instance of the connection.
    in your midlet place the ui initialization in its constructor
    ok, Why dont you try the query in the url
    i.e http://localhost:8080/Magazijn/query=";
    then as you input the product id without setting requests
    c = (HttpConnection)Connector.open(url+productid);
    i think it will work properly
    tell me what happens with you

  • Parameters from midlet to servlet

    Hi all,
    i have been trying to pass values from MIDlet (setRequestProperty(); ) and to servlet (request.getParameter();).
    but when i tried to print out the value, it just contained NULL value.
    I had a look at the java forum website, there were plenty of same problems and no one got right.
    I'll really appreciate it if anyone fixes this for me.
    ---------------------MIDLET-----------------------------------------------------------------------------
    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;
    import javax.microedition.io.*;
    import java.io.*;
    import java.util.*;
    import org.kxml.*;
    import org.kxml.parser.*;
    public class MbankMIDlet  extends MIDlet implements CommandListener {
      private Display display;
      private Form loginForm = new Form("Login");
      private Form mainForm = new Form("MobileBank");
      private String loguserID;
      private String logpass;
      private String mSession;
      private StringItem stringItem = new StringItem(null,"");
      private TextField userIDTextField = new TextField("User ID", "", 8, TextField.NUMERIC);
      private TextField passwordTextField = new TextField("Password", "", 12, TextField.PASSWORD);
      static final Command loginCommand = new Command("Login", Command.OK, 1);
      static final Command exitCommand = new Command("Exit", Command.STOP, 1);
      static final Command backCommand = new Command("Back",Command.BACK, 1);
      public MbankMIDlet() {
        mainForm.append(stringItem);
        mainForm.addCommand(exitCommand);
        mainForm.addCommand(backCommand);
        mainForm.setCommandListener(this);
      public void startApp() throws MIDletStateChangeException {
        display = Display.getDisplay(this);
        loginForm.append(userIDTextField);
        loginForm.append(passwordTextField);
        loginForm.addCommand(loginCommand);
        loginForm.addCommand(exitCommand);
        loginForm.addCommand(backCommand);
        loginForm.setCommandListener(this);
        display.setCurrent(loginForm);
      public void destroyApp(boolean unconditional) {
        notifyDestroyed();
      public void mainMenu() {
        display.setCurrent(loginForm);
      public void pauseApp() {
        display = null;
        loginForm = null;
        mainForm = null;
        stringItem = null;
        userIDTextField = null;
        passwordTextField = null;
      public void commandAction(Command c, Displayable d) {
        String label = c.getLabel();
        if (label.equals("Exit")) {
          destroyApp(true);
           mSession = null;
        } else if (label.equals("Login")) {
          login();
        } else if (label.equals("Back")){
          mainMenu();
      private void login() {
        loguserID = userIDTextField.getString();
        logpass = passwordTextField.getString();
        Form waitForm = new Form("Waiting...");
        display.setCurrent(waitForm);
        Thread t = new Thread() {
          public void run() {
            connect();
        t.start();
      private void connect() {
        HttpConnection hc = null;
        InputStream in = null;
        OutputStream os = null;
        String url = getAppProperty("MbankMIDlet.URL");
        try {
          hc = (HttpConnection)Connector.open(url);
          hc.setRequestMethod(HttpConnection.GET);
          hc.setRequestProperty("User-Agent", "Profile/MIDP-1.0 Configuration/CLDC-1.0" );
          hc.setRequestProperty("Content-Language", "en-US" );
          hc.setRequestProperty("Accept", "text/plain");
          hc.setRequestProperty("Content-Type", "application/x-www-form-urlencoded" );
          hc.setRequestProperty("Connection","close");
          hc.setRequestProperty("loguserID", loguserID);
          hc.setRequestProperty("logpass", logpass);
          os = hc.openOutputStream();
          os.close();
    //      os.flush();  //tried close() and flush() but none of them worked.
          if (mSession != null) {
              hc.setRequestProperty("Cookie", mSession);
          // Read the session ID from a cookie in the response headers.
          String cookie = hc.getHeaderField("Set-cookie");
          if (cookie != null) {
              int semicolon = cookie.indexOf(';');
              mSession = cookie.substring(0, semicolon);
          in = hc.openInputStream();
          int rc = hc.getResponseCode();
          if( rc == HttpConnection.HTTP_OK ) { //HTTP_OK equals 200
            System.out.println("HttpConnection OK");
            StringBuffer xmlBuffer = new StringBuffer();
            String xmlString = null;
            int ch;
            while ( ( ch = in.read() ) != -1 )
              xmlBuffer.append( ( char )ch );
            xmlString = xmlBuffer.toString();
            stringItem.setText(xmlString);
          else if (rc == HttpConnection.HTTP_UNAUTHORIZED){//HTTP_UNAUTHORIZED equals 401
            System.out.println("HttpConnection Unauthorized");
            int contentLength = (int)hc.getLength();
            byte[] raw = new byte[contentLength];
            int length = in.read(raw);
            String s = new String(raw,0,length);
            stringItem.setText(s);
          in.close();
          hc.close();
        catch (IOException ioe) {
          stringItem.setText(ioe.toString());
        finally {
          display.setCurrent(mainForm);
    }---------------SERVLET----------------------------------------------------------------------------
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.util.*;
    import java.io.*;
    public class LoginServlet extends HttpServlet {
        public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
              HttpSession session = request.getSession();
              response.setContentType("text/plain");
              PrintWriter out = response.getWriter();
              String userID, password, userRole = null;
              try {
                                  userID = (String)request.getParameter("loguserID");
                  password = (String)request.getParameter("logpass");
                  System.out.println(userID); // "Null printed"              System.out.println(password);  // "Null printed"
              catch (Exception e) {
                   //If anything goes wrong, print the Exception message
                  e.printStackTrace(out);
    }Thanks.

    getParameter() can't parse the input stream well if there is any issues in the sent content. this is true, with varying mobile phone http impl.
    You would find the content at servlet, by using request.getInputStream() and reading the entire content.
    Here is the sample code:
    public static String readMobileData(final HttpServletRequest aRequest) throws Exception
         String lData = null;
         Enumeration params = aRequest.getParameterNames();
         while (params.hasMoreElements())
         //from real Nokia 6600 Mobile the request is sent as param, though
         //it is post
         String lName = params.nextElement().toString();
         lData = aRequest.getParameter(lName);
         System.out.println("\nParameter:" + lName + "=" + lData);
         if (lData == null)
         //in emulator the data is coming as inputstream
         ServletInputStream in = aRequest.getInputStream();
         DataInputStream dIn = new DataInputStream(in);
         lData = dIn.readUTF();
         lData = lData.substring(lData.indexOf("=") + 1);
         System.out.println("Stream Request:\n" + lData);
         return lData;
    Regards,
    Raja Nagendra Kumar,
    C.T.O,
    When Teja is Tasked, the Job Gets Done
    www.tejasoft.com

  • [Request For Help] How To Send Email Midlet Using Secure Socket ?

    Hello, this is the first time i ask for help to forum.sun.com.
    i try to make secure connection for send email from MIDlet. Maybe you can check to my code :
    EmailMidlet.java
    import javax.microedition.midlet.MIDlet;
    import javax.microedition.midlet.MIDletStateChangeException;
    import javax.microedition.lcdui.;
    public class EmailMidlet extends MIDlet implements CommandListener{
    Display display = null;
    // email form fields
    TextField toField = null;
    TextField subjectField = null;
    TextField msgField = null;
    Form form;
    static final Command sendCommand = new Command("send", Command.OK, 2);
    static final Command clearCommand = new Command("clear", Command.STOP, 3);
    String to;
    String subject;
    String msg;
    public EmailMidlet() {
    display = Display.getDisplay(this);
    form = new Form("Compose Message");
    toField = new TextField("To:", "", 50, TextField.EMAILADDR);
    subjectField = new TextField("Subject:", "", 15, TextField.ANY);
    msgField = new TextField("MsgBody:", "", 90, TextField.ANY);
    public void startApp() throws MIDletStateChangeException {
    form.append(toField);
    form.append(subjectField);
    form.append(msgField);
    form.addCommand(clearCommand);
    form.addCommand(sendCommand);
    form.setCommandListener(this);
    display.setCurrent(form);
    public void pauseApp() {
    public void destroyApp(boolean unconditional) {
    notifyDestroyed();
    public void commandAction(Command c, Displayable d) {
    String label = c.getLabel();
    if(label.equals("clear")) {
    destroyApp(true);
    } else if (label.equals("send")) {
    to = toField.getString();
    subject = subjectField.getString();
    msg = msgField.getString();
    EmailClient client = new EmailClient(this,"[email protected]", to, subject, msg);
    client.start();
    }and EmailClient.java
    import javax.microedition.io.;
    import javax.microedition.lcdui.;
    import java.io.;
    import java.util.Date;
    public class EmailClient implements Runnable {
    private EmailMidlet parent;
    private Display display;
    private Form f;
    private StringItem si;
    private SecureConnection sc; //SSL
    private InputStream is;
    private OutputStream os;
    private String smtpServerAddress = "smtp.gmail.com"; //SSL
    String from;
    String to;
    String subject;
    String msg;
    public EmailClient(EmailMidlet m, String from, String to, String subject, String msg) {
    parent = m;
    this.from = from;
    this.to = to;
    this.subject = subject;
    this.msg = msg;
    display = Display.getDisplay(parent);
    f = new Form("Email Client");
    si = new StringItem("Response:" , " ");
    f.append(si);
    display.setCurrent(f);
    public void start() {
    Thread t = new Thread(this);
    t.start();
    public void run() {
    try {
    //SSL
    sc = (SecureConnection)
    Connector.open("ssl://"smtpServerAddress":465"); //smtp with SSL port 465
    sc.setSocketOption(SocketConnection.LINGER, 5);
    is = sc.openInputStream();
    os = sc.openOutputStream();
    os.write(("HELO there" "\r\n").getBytes());
    os.write(("EHLO" "\r\n").getBytes());
    os.write(("auth login" "\r\n").getBytes());
    os.write(("dHVnYXNha2hpci50cmlhZGl0eWFAZ21haWwuY29t" "\r\n").getBytes());
    os.write(("dGEuZW1haWxjbGllbnQ=" "\r\n").getBytes());
    os.write(("MAIL FROM:<">\r\n").getBytes());
    os.write(("RCPT TO:<">\r\n").getBytes());
    os.write("DATA\r\n".getBytes());
    // stamp the msg with date
    os.write(("Date: " new Date() "\r\n").getBytes());
    os.write(("From: "+from"\r\n").getBytes());
    os.write(("To: "to"\r\n").getBytes());
    os.write(("Subject: "subject"\r\n").getBytes());
    os.write((msg+"\r\n").getBytes()); // message body
    os.write(".\r\n".getBytes());
    os.write("QUIT\r\n".getBytes());
    StringBuffer sb = new StringBuffer();
    int ch = 0;
    while((ch = is.read()) != -1) {
    sb.append((char) ch);
    si.setText("SMTP server response - " + sb.toString());
    } catch(IOException e) {
    e.printStackTrace();
    Alert a = new Alert
    ("TimeClient", "Cannot connect to SMTP server. Ping the server to make sure it is running...", null, AlertType.ERROR);
    a.setTimeout(Alert.FOREVER);
    display.setCurrent(a);
    } finally {
    try {
    if(is != null) {
    is.close();
    if(os != null) {
    os.close();
    if(sc != null) {
    sc.close();
    } catch(IOException e) {
    e.printStackTrace();
    public void commandAction(Command c, Displayable s) {
    if (c == Alert.DISMISS_COMMAND) {
    parent.notifyDestroyed();
    parent.destroyApp(true);
    } When I try to debug project from netbeans, i found this error :
    Starting emulator in debug server mode on port 2668
    Connecting to 127.0.0.1 on port 2800
    nbdebug:
    Waiting for debugger on port 2668
    Waiting for KVM...
    Running with storage root temp.SonyEricsson_JP8_128x160_Emu10
    KdpDebugTask connecting to debugger 1 ..
    Running with locale: Indonesian_Indonesia.1252
    Connected to KVM
    Connection received.
    Attached JPDA debugger to localhost:2668
    java.io.IOException: error 10054 during TCP read +
    at com.sun.midp.io.j2me.socket.Protocol.nonBufferedRead(Protocol.java:299)+
    at com.sun.midp.io.BufferedConnectionAdapter.readBytes(BufferedConnectionAdapter.java:99)+
    at com.sun.midp.io.BaseInputStream.read(ConnectionBaseAdapter.java:582)+
    at com.sun.midp.ssl.Record.rdRec(+41)+
    at com.sun.midp.ssl.Record.rdRec(+5)+
    at com.sun.midp.ssl.In.refill(+18)+
    at com.sun.midp.ssl.In.read(+29)+
    at EmailClient.run(EmailClient.java:74)+
    Execution completed.
    5145824 bytecodes executed
    9258 thread switches
    1762 classes in the system (including system classes)
    0 dynamic objects allocated (0 bytes)
    0 garbage collections (0 bytes collected)
    debug:
    BUILD SUCCESSFUL (total time: 4 minutes 34 seconds)
    Regard
    Littlebro

    Don't multipost and don't use the browser's back button to edit your posts as that creates multiple postings. I've removed the other thread you started with the same questio.
    Also, don't post to long dead threads. I've blocked your post and locked the thread you resurrected.
    db

  • Need help to access a web page using midlet to retrieve some informations

    Hi everyone i'm trying to access a web page using midlet to retrieve some informations in text format, the web page is [http://daviddurand.info/D228/?villes|http://daviddurand.info/D228/?villes] for my project.
    the problem is that i always get error 10049 in socket::open meaning no adresse could be found i tried IP adresse and still the same.
    i managed to recreate the same web page to test it on local and the surprise that it works fine but when accessing it online i have this error.
    i tried also to get the page i created on a webserver i own to try it saying that there might be security issues but the same error appears again. so help plz
    here is my code :
    package mobileapplication5;
    import java.io.*;
    import javax.microedition.io.*;
    import javax.microedition.lcdui.*;
    import javax.microedition.midlet.*;
    public class GetMidlet extends MIDlet {
    private Display display;
    String url = "http://dayaati.com/villes/index.php?villes";
    public GetMidlet() {
    display = Display.getDisplay(this);
    public void startApp() {
    try {
    getBirthdayFromNameUsingGet(url);
    } catch (IOException e) {
    System.out.println("IOException " + e);
    e.printStackTrace();
    public void pauseApp() {   }
    public void destroyApp(boolean unconditional) {  }
    public void getBirthdayFromNameUsingGet(String url) throws IOException {
              HttpConnection httpConn = null;
              InputStream is = null;
              OutputStream os = null;
              try {
    httpConn = (HttpConnection)Connector.open(url);
    httpConn.setRequestProperty("User-Agent", "Profile/MIDP-2.1 Configuration/CLDC-1.1");
    httpConn.setRequestProperty("Content-Language", "en-US" );
    httpConn.setRequestProperty("Content-Type", "text/html; charset=iso-8859-1");
    httpConn.setRequestProperty( "Connection", "keep-alive" );
    httpConn.setRequestProperty("Content-Length","51200");
              getConnectionInformation(httpConn);
              int respCode = httpConn.getResponseCode();
              if (respCode == httpConn.HTTP_OK) {
                   StringBuffer sb = new StringBuffer();
                   os = httpConn.openOutputStream();
                   is = httpConn.openDataInputStream();
                   int chr;
                   while ((chr = is.read()) != -1)
                   sb.append((char) chr);
                   // Web Server just returns the birthday in mm/dd/yy format.
                   System.out.println(sb.toString());
              else {
                   System.out.println("Error in opening HTTP Connection. Error#" + respCode);
              } finally {
                   if(is!= null)
                   is.close();
                   if(os != null)
                        os.close();
              if(httpConn != null)
                        httpConn.close();
    void getConnectionInformation(HttpConnection hc) {
    System.out.println("Request Method for this connection is " + hc.getRequestMethod());
    System.out.println("URL in this connection is " + hc.getURL());
    System.out.println("Protocol for this connection is " + hc.getProtocol());
    System.out.println("This object is connected to " + hc.getHost() + " host");
    System.out.println("HTTP Port in use is " + hc.getPort());
    System.out.println("Query parameter in this request are " + hc.getQuery());
    **Heeeeeeelp Please**

    [http://java.sun.com/javase/6/webnotes/trouble/TSG-VM/html/crashes.html]
    SIGSEGV (0xb)Most common cause of that is JNI code used directly or indirectly through a 3rd party library.
    64-Bit Server VM (11.2-b01 mixed mode linux-amd64)Conversely that VM gets less traffic than others so you might have hit a bug in it.

  • Error in running MIDlet

    Hi, all
    I have a problem around MIDlet.
    Here, the MIDlet source code :
    import javax.microedition.lcdui.*;
    import javax.microedition.midlet.*;
    import javax.microedition.io.*;
    import java.io.*;
    public class BolaMidlet extends Form implements CommandListener
    +{     +
    private Display display;
    private static final Command cmExit = new Command("Keluar", Command.EXIT, 1);
    private static final Command cmSubmit = new Command("Login", Command.OK, 1);
    private BolaMidlet midlet;
    private TextField tfUsername;
    private TextField tfMajor;
    private String result;
    public BolaMidlet(BolaMidlet midlet, Display display)
    +{+
    super("BolaMidlet");
    this.midlet = midlet;
    this.display = display;
    tfUsername = new TextField("Username", "", 20, TextField.ANY);
    tfMajor = new TextField("Major", "", 20, TextField.ANY);
    append(tfUsername);
    append(tfMajor);
    addCommand(cmExit);
    addCommand(cmSubmit);
    setCommandListener(this);
    +}+
    public void startApp()
    +{+
    display.setCurrent(this);
    +}+
    public void pauseApp()
    +{+
    display.setCurrent(null);
    +}+
    public void destroyApp(boolean unconditional)
    +{+
    +}+
    public void exitMIDlet()
    +{+
    destroyApp(false);          
    +}     +
    public void commandAction(Command c, Displayable s)
    +{+
    if(c == cmExit)
    +{+
    midlet.exitMIDlet();
    +}+
    else if(c == cmSubmit)
    +{+
    try
    +{+
    submit(tfUsername.getString(), tfMajor.getString());
    +}catch(Exception e)+
    +{+
    e.printStackTrace();
    +}+
    +}          +
    +}+
    public void submit(String user, String major)
    throws IOException
    +{+
    String url = "http://localhost:8080/hello/sayhello?user=user&pass=major";
    HttpConnection hc = null;
    StringBuffer sb = null;
    InputStream is = null;
    try
    +{+
    hc = (HttpConnection)Connector.open(url, Connector.READ_WRITE);
    hc.setRequestMethod(HttpConnection.GET);
    hc.setRequestProperty("User-Agent", "Profile/MIDP-2.1 Configuration/CLDC-1.1");
    hc.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
    if(hc.getResponseCode() == HttpConnection.HTTP_OK)
    +{+
    sb = new StringBuffer();
    int ch;
    is = hc.openInputStream();
    while((ch = is.read()) != -1)
    sb.append((char)ch);
    +}+
    else
    +{+
    System.out.println("Network error");
    +}     +
    +}catch(IOException e)+
    +{+
    e.printStackTrace();
    if(hc != null)
    hc.close();
    if(sb != null)
    result = sb.toString();
    if(is != null)
    is.close();
    +}finally+
    +{+
    if(is != null)                    
    is.close();                    
    if(sb != null)               
    result = sb.toString();                    
    if(hc != null)                    
    hc.close();                    
    +}+
    +}+
    when I compiled it, there was no problem.
    But, when I launched it on the emulator
    there was an error in WTK console like this :
    Unable to create MIDlet BolaMidlet
    java.lang.IllegalAccessException
    at com.sun.midp.midlet.MIDletState.createMIDlet(34)+
    at com.sun.midp.midlet.Selector.run(22)+
    and then the emulator said : BolaMidlet, BolaMidlet exception : java.lang.IllegalAccessException
    can someone help me to solve this ?
    I really need help for this one.
    Thank You,
    Best Regards,
    CHi
    Edited by: ichiwan on Sep 30, 2007 11:23 AM

    {color:#000080}The code you have posted is for a class that extends Form, not MIDlet.
    To post code, use code tags --{color} [code]CODE[/code] {color:#000080}is displayed as CODEPlease do not try to format parts of your code as bold or italic as that reduces the readability still more.
    db{color}

  • Error while executing the midlet ----pleasehelp

    Hi everyone,
    I am new to webservices, I am trying to execute a webservice from a midlet. Iam getting the below error.
    java.lang.NoClassDefFoundError: org/kxmlrpc/XmlRpcClient
         at kxmlrpc_demo.commandAction(+49)
         at javax.microedition.lcdui.List.callKeyPressed(+80)
         at javax.microedition.lcdui.Display$DisplayAccessor.keyEvent(+198)
         at javax.microedition.lcdui.Display$DisplayManagerImpl.keyEvent(+11)
         at com.sun.midp.lcdui.DefaultEventHandler.keyEvent(+121)
         at com.sun.midp.lcdui.AutomatedEventHandler.keyEvent(+210)
         at com.sun.midp.lcdui.DefaultEventHandler$QueuedEventHandler.run(+178)
    Below is my midlet code.
    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;
    import javax.microedition.io.*;
    import java.io.*;
    import java.util.*;
    import org.kxmlrpc.*;
    public class MyMidlet extends MIDlet implements CommandListener {
         private List list;
         private Command exitCommand;
         private String[] menuItems;
         private Display display;
         private Alert response;
         private XmlRpcClient xmlrpc;
         private Vector params, xmlArray;
         public MyMidlet() {
              // Initialize the User Interface
              menuItems = new String[] { "Timestamp", "Randomizer", "AddressBook" };
              list = new List("Select a service", List.IMPLICIT, menuItems, null);
              exitCommand = new Command("Exit", Command.EXIT, 1);
              response = new Alert("Service Return", null, null, AlertType.INFO);
              response.setTimeout(Alert.FOREVER);
              // Add commands
              list.addCommand(exitCommand);
              list.setCommandListener(this);
              // obtain a reference to the device's UI
              display = Display.getDisplay(this);
         }// end MyMidlet()
         public void startApp() {
              display.setCurrent(list);
         }// end startApp()
         public void pauseApp() {
         }// end pauseApp()
         public void destroyApp(boolean bool) {
              // clean up
              list = null;
              exitCommand = null;
              display = null;
         }// end destroyApp
         public void commandAction(Command com, Displayable dis) {
              if (dis == list && com == List.SELECT_COMMAND) {
                   switch (list.getSelectedIndex()) {
                   case 0:
                        try {
                             xmlrpc = new XmlRpcClient(
                                       "<a href=http:// www.wsjug.org/servlet/XmlRpcServlet EUDORA=AUTOURL> http:// www.wsjug.org/servlet/XmlRpcServlet/a>");
                             params = new Vector();
                             String serverTime = (String) xmlrpc.execute(
                                       "sysTime.getSystemTime", params);
                             response.setString(serverTime.toString());
                             display.setCurrent(response);
                        } catch (Exception ex) {
                             response.setString(ex.toString());
                             ex.printStackTrace(); // DEBUG
                             display.setCurrent(response);
                        }// end try/catch
                        break;
                   case 1:
                   case 2:
                        response.setString("Please download the full sample code");
                        display.setCurrent(response);
                        break;
                   }// end switch( list.getSelectedIndex() )
              } else if (com == exitCommand) {
                   destroyApp(true);
                   notifyDestroyed();
              }// end if( dis == list &&
              com = List.SELECT_COMMAND;
         }// end CommandAction( Command, Displayable )
    }// end MyMidlet
    I think the problem here is with the kxml.jar file which I have placed every where I find the lib folder. Could anyone please tell me where to exactly place the kxml.jar file?
    I am using Myeclipse IDE.
    Please help.
    Thanks in advance.
    Regards,
    Bharat Kumar

    Hi Vamsi.
    The exactly erro refers to a problems when you try upgrade from these version to 11.5.10.
    Can you read this note and apply solution? The note refers a patch, but the problem is the same.
    After Patch 4334965, adstrtal.sh & adstpall.sh is failing with errors [ID 360046.1]
    BR Rafael Ceolim

  • Blackberry controls and midlets

    Midlet meets blackberry let the battle for who can use the escape key begin!
    If you're having trouble mapping keys from the blackberry to your midlet..this will definitely help you!
    in this post I go over: Adding menu items to the blackberry menu, and gaining access to undetected keys such as the Escape Key.
    First of all, that **** menu how do I add stuff to it?
    Well...that in itself is a hastle but lemme just say, that menu
    is in a nutshell a CommandListener. Same freakin menu. Later on in this post I show how to map the escape key..and i'm guessing pretty much every other key...of course
    the only key I ever had a problem with was the EscapeKey/HangUpKey
    Anyways if you want that BlackBerry Menu Code here
    * MIDletDemo.java
    * Copyright &copy; 1998-2008 Research In Motion Ltd.
    * Note: For the sake of simplicity, this sample application may not leverage
    * resource bundles and resource strings.  However, it is STRONGLY recommended
    * that application developers make use of the localization features available
    * within the BlackBerry development platform to ensure a seamless application
    * experience across a variety of languages and geographies.  For more information
    * on localizing your application, please refer to the BlackBerry Java Development
    * Environment Development Guide associated with this release.
    import java.util.*;
    import java.io.*;
    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;
    import java.lang.*;
    * An Example MIDlet.
    * The application must extend the MIDlet class to allow the application management
    * software to control the MIDlet.
    public class MIDletDemo extends MIDlet implements CommandListener
        private Alert _alert;
        private int _time;
        private Form _form;
        private myCanvas customCanvas;
        private Display _display;
        private UpdateThread _updateThread;
         * The thread that updates the explosion dialog box.
        private class UpdateThread extends Thread
            private boolean _disarmed;
            public void run()
                _disarmed = false;
                int i = _time;
                while (i > 0 && !_disarmed)
                    try
                        _alert.setString(Integer.toString(i));
                        synchronized(this)
                                this.wait(1000);
                        System.out.println("timeout in:" +i);
                    catch(InterruptedException e)
                        System.out.println("MyMidlet: Exception: " + e);
                    i--;
                if(!_disarmed)
                    _alert.setString("BOOM");
            void disarm()
                _disarmed = true;
         * Thread that pops up the program's main dialog box.
        private class GoCommand extends Command implements Runnable
            private GoCommand(String label, int type, int priority)
                super(label, type, priority);
            public void run()
                _alert.setString(Integer.toString(_time));
                _alert.setTimeout(_time * 1000 + 5000);
                _updateThread = new UpdateThread();
                _updateThread.start();
                _display.setCurrent(_alert, _form);
         * <p>The default constructor. Creates a simple screen and a command with an alert
         * dialog box which pops up when the command is selected.
        public MIDletDemo()
            _alert = new Alert("The Thermonuclear Device has been activated!\nTo disarm the device, dismiss this Alert.\nDevice will detonate in:");
            _alert.setCommandListener(this);
            _time = 10;
            // Create a simple screen.
            _form = new Form("Thermo-Nuclear Event");
          _form.append("Choose 'Go' from the menu.");
         customCanvas = new myCanvas();
            _display = Display.getDisplay(this);
            // Add our command.
            //_form.addCommand(new GoCommand("Go", Command.SCREEN, 1));
    customCanvas.addCommand(new GoCommand("Go", Command.SCREEN, 1));
    customCanvas.setCommandListener(this);
            //_form.setCommandListener(this);
            _display.setCurrent(customCanvas);
        //_display.setCurrent(_form);
        public void commandAction(Command c, Displayable s)
            if ( c instanceof Runnable )
                ((Runnable)c).run();
            if( c == Alert.DISMISS_COMMAND )
                _updateThread.disarm();
            _display.setCurrent(playerGUI);
         * <p>Signals the MIDlet that it has entered the Active state.
        public void startApp()
            // Not implemented.
         * <p>Signals the MIDlet to stop and enter the Pause state.
        public void pauseApp()
            // Not implemented.
         * <p>Signals the MIDlet to terminate and enter the Destroyed state.
         * @param unconditional When set to true, the MIDlet must cleanup and release all
         * resources. Otherwise, the MIDlet may throw a MIDletStateChangeException to
         * indicate it does not want to be destroyed at this time.
        public void destroyApp(boolean unconditional)
            // Not implemented.
    }now keep in mind, I took this from a nice little example MIDlet called DemoMidlet inside the BlackBerry JDE
    so it's not like they didn't make an effort. I mean I pretty much took it out of their examples located in
    C:\Program Files\Research In Motion\BlackBerry JDE 4.6.0\samples\com\rim\samples\device\midletdemo
    but lets face it...some of us like to use the Canvas Class...so showing us how to use it with a Form not exactly helpful.
    All I did was the same thing it's just I made a canvas, and implemented the CommandListener, then swapped their form for my canvas.
    It freaking worked like a charm. I mean I didn't really use that alert stuff...as it wasn't necessary, but it's a nice demo to learn from.
    Part 2: The Escape Key!
    The first and only problem I noticed when porting over to the blackberry was the lack of certain keys
    that I truly enjoy and need. I guess blackberry decided to just not implement them
    into the MIDlet canvas class?
    I mean they did a great job at figuring out how to map the entire qwerty keyboard, but when it comes to the Escape Key
    good luck!
    So after tearing my hair out I found a solution...which i'm guessing everyone else also found but i'm posting this
    cuz well..what if you're tearing your hair out right now...calm down take a deep breaths this is currently working on the BB 9000
    jde emulator.
    First of all I know this sucks but if you want to use that lovely escape key you're going to have to implement the BB KeyListener.
    I know WTF MAN!? "first i code the whole thing using keylistener/commandlistener now I gotta use some stupid BB KEYLISTENER!?...just who does blackberry think they are?"
    well heres the thing, I tore my hair out for like 12 hours straight trying to get around this...but after giving it a rest it's not such a big deal.
    Steps
    1) you have to grab the blackberry net_rim_api, and add it to your wireless toolkit.
    the path is:
    C:\Program Files\Research In Motion\BlackBerry JDE 4.6.0\lib\net_rim_api.jar
    what I did was copied the file and pasted it into
    C:\WTK2.5.1\lib\ext
    once you have that inside your ext folder in your project settings you can enable the external package, this way you can build
    using the RIM API.
    in case you wanta take a glance at that headache it's : http://www.blackberry.com/developers/docs/4.5.0api/index.html
    to enable it simply open up wtk, go to project/settings/External API's and check it off...take note that the wtk 2.5 generally comes with
    Nokia SNAP Mobile API so i'm guessing it's a normal thing to do with MIDlets. Also if you check off Bundle..that's not too good it includes the API
    with your package...which is really only helpful if you're trying to include some of that junk which really isn't necessary as the reason we're doing this in the first
    place is cuz blackberry wanted to be cool and have their own proprietary keys....
    Anyways check that off and continue to step 2.
    Implementing Key Listener with the Canvas Class! :-)
    2) This part is so easy...
    import java.io.*;
    import javax.microedition.lcdui.*;
    import javax.microedition.midlet.*;
    import net.rim.device.api.system.*;
    public class myCanvas extends Canvas implements CommandListener,KeyListener{
    String thekey = "no key pressed yet";
      public myCanvas() {
    Application.getApplication().addKeyListener(this);
    public void paint(Graphics g){
    g.setColor(255,255,255);
    g.fillRect(0,0,500,500);
    g.setColor(0,0,0);
    g.drawString(thekey,0,0,Graphics.TOP|Graphics.LEFT);
    public boolean keyDown(int keycode, int time)
                    thekey = String.valueOf(keycode);
                    repaint();
                return false;
            public boolean keyRepeat(int keycode, int time)
                 return false;
            public boolean keyStatus(int keycode, int time)
                  return false;
            public boolean keyUp(int keycode, int time)
                   return false;
      public boolean keyChar(char key, int status, int time) {
          if (key == Characters.ESCAPE)
             return false;
    public void commandAction(Command c, Displayable s)
      ///YOU DON'T NEED THIS! I just left it here, in case you wanted to also use the blackberry menu to do stuff...in this case
    //well the command is shown...and it calls the run method of the class you add the command to. My previous example
    // used the command GO, and i made a private class...so this would cause the run method to execute when the user hits enter on go.     
         // if ( c instanceof Runnable )
              //  ((Runnable)c).run();
    }i'm gonne be honest with you, the function public boolean keyChar()
    I don't know if that actually works...I just don't want to recompile without it cuz I just got over this headache..so I left it there.
    According to most people you use that to check if the key == Characters.ESCAPE and if it does then you do some stuff.
    Also you don't need the command listener, I just left it in there because well..if you're like me and you use the blackberry menu, you're pretty much
    going to use the CommandListener on your canvas to check to see if the user hit enter on a menu item.
    The function that matters here, is the same function Midlet coders are used to.
    instead of keyPressed it's simply keyDown
    so basically you're importing the package
    import net.rim.device.api.system.*;
    which allows you to implement blackberry's keyListener which gives you access to all the keys vs. a limited amount of them.
    now blackberry went all out as you can see. You have to have keyDown, keyUp, keyRepeated...it's kinda rediculous.
    but no worries, as long as you make sure that Display.setCurrent(yourcanvas);
    or you use one of those to give the canvas control...you'll be fine.
    It works because in the method for creating myCanvas()
    or whatever canvas you'll be using, it calls Application.getApplication.addKeyListener(this);
    and that little command gives your canvas the ability to listen for blackberry keys such as escape.
    the current code will start displaying the keycodes for each key...and apparently keys such as ESCAPE
    can be labeled properly. I love this because I can map the hang up call key to destroy my midlet, or even the escape key.
    Unfortunately every keycode displayed is in like unicode or some stupid format, so that's my guess as to why the Escape key is not detected by the normal
    canvas keyPressed method.
    Anyways you're done this should work...now if you're having trouble using canvas and you're like "but I don't use canvas" idk man...
    I use canvas...cuz I think programs should look cool. I'm sure this works without the canvas...on a form or something.
    But don't be fooled, you're not limited to KeyListener, you can also use TrackWheelEvent and all kinds of stuff. So just like the choices for CommandListener vs. keyPressed
    Blackberry has other choices as well.
    And they said merging the API's was a bad idea...shucks, how else are we supposed to use the freaking escape key.
    --JavaLover53
    P.S. I marked this as a question cuz I want people to really take a look at this. Make some comments, I love this forum
    and I really feel that this topic is not covered on the internet. A lot of naysayers, and when I found the solution I was like "that's it"
    "that's all I had to do?" "well then wheres the freaking tutorial!
    seriously people had me thinking I had to extend the blackberry UI when this is all I had to do..such an easy task
    that other people claim is ridiculously hard.
    Go ahead make your comments, lemme know if you know something I don't, i'm here to learn! :-)

    good writeup, however i found this only working when you're not running fullscreen

  • Problems with a simple Midlet

    Hi , i'm trying to run a simple Midlet with a list, but appear the following errors:
    Error running executable C:\WTK22\bin\zayit
    java.net.SocketException: No buffer space available (maximum connections reached?): JVM_Bind
         at java.net.PlainSocketImpl.socketBind(Native Method)
         at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:359)
         at java.net.ServerSocket.bind(ServerSocket.java:319)
         at java.net.ServerSocket.<init>(ServerSocket.java:185)
         at java.net.ServerSocket.<init>(ServerSocket.java:97)
         at com.sun.kvem.Lime.runClient(Unknown Source)
         at com.sun.kvem.KVMBridge.runKVM(Unknown Source)
         at com.sun.kvem.KVMBridge.runKVM(Unknown Source)
         at com.sun.kvem.midp.MIDP$4.run(Unknown Source)
    the code of the Midlet is so simple and i don't know what happen.
    i hope that you can help me
    thanks

    the code is:
    package componentes;
    import javax.microedition.lcdui.*;
    import javax.microedition.midlet.*;
    public class InterfazMid extends MIDlet implements CommandListener {
    private Display display;
    private List menu;
    private List lista;
    private TextBox cajaTexto;
    private Form form;
    private DateField campoFecha;
    private Gauge indicador;
    private TextField campoTexto;
    private Ticker ticker;
    private Alert aviso;
    private Image imagen;
    private Command atras;
    private Command menuPrincipal;
    private Command salir;
    String menuActual = null;
    public InterfazMid() {
    form = new Form( "Formulario" );
    indicador = new Gauge( "Indicador",false,50,20 );
    campoTexto = new TextField( "Campo de texto","abc",40,0 );
    ticker = new Ticker( "Componentes de la intefaz MIDP" );
    aviso = new Alert( "Aviso Sonoro" );
    imagen = Image.createImage( "/error.png" );
    } catch( Exception e ) {}
    atras = new Command( "Atr�s",Command.BACK,0 );
    menuPrincipal = new Command( "Men� Ppal",Command.SCREEN,1 );
    salir = new Command( "Salir",Command.STOP,2 );
    protected void startApp() {
    display = Display.getDisplay( this );
    menu = new List( "Interfaz MIDP",Choice.IMPLICIT );
    menu.append( "Caja de texto",null );
    menu.append( "Fecha",null );
    menu.append( "Lista",null );
    menu.append( "Aviso",null );
    menu.append( "Formulario",null );
    menu.addCommand( salir );
    menu.setCommandListener( this );
    menu.setTicker( ticker );
    mainMenu();
    protected void pauseApp() {}
    protected void destroyApp( boolean flag ) {}
    public void mainMenu() {
    menuActual = "Men� Ppal";
    display.setCurrent( menu );
    public void testTextBox() {
    cajaTexto = new TextBox( "Teclea algo:","",10,TextField.ANY );
    cajaTexto.setTicker( new Ticker("Probando TextBox") );
    cajaTexto.addCommand( atras );
    cajaTexto.setCommandListener( this );
    cajaTexto.setString( "ABC" );
    display.setCurrent( cajaTexto );
    menuActual = "texto";
    public void testList() {
    lista = new List( "Seleciona:",Choice.MULTIPLE );
    lista.setTicker( new Ticker("Probando List") );
    lista.addCommand( atras );
    lista.setCommandListener( this );
    lista.append( "Opci�n 1",null );
    lista.append( "Opci�n 2",null );
    lista.append( "Opci�n 3",null );
    lista.append( "Opci�n 4",null );
    display.setCurrent(lista);
    menuActual = "lista";
    public void testAlert() {
    aviso.setType( AlertType.ERROR );
    aviso.setImage( imagen );
    aviso.setString( " ** ERROR **" );
    display.setCurrent( aviso );
    public void testDate() {
    java.util.Date fecha = new java.util.Date();
    campoFecha = new DateField( "Hoy es: ",DateField.DATE );
    campoFecha.setDate( fecha );
    Form f = new Form( "Fecha" );
    f.append( campoFecha );
    f.addCommand( atras );
    f.setCommandListener( this );
    display.setCurrent( f );
    menuActual = "fecha";
    public void testForm() {
    form.append( campoTexto );
    form.append( indicador );
    form.addCommand( atras );
    form.setCommandListener( this );
    display.setCurrent( form );
    menuActual = "form";
    public void commandAction( Command c,Displayable d ) {
    String label = c.getLabel();
    if( label.equals("Salir") ) {
    destroyApp( true );
    notifyDestroyed();
    else if (label.equals("Atr�s")) {
    if( menuActual.equals( "lista" ) ||
    menuActual.equals( "texto" ) ||
    menuActual.equals( "fecha" ) ||
    menuActual.equals( "form" ) ) {
    mainMenu();
    else {
    List l = (List)display.getCurrent();
    switch( l.getSelectedIndex() ) {
    case 0:
    testTextBox();
    break;
    case 1:
    testDate();
    break;
    case 2:
    testList();
    break;
    case 3:
    testAlert();
    break;
    case 4:
    testForm();
    break;
    the code is so simple. i think that the problem is on the j2me wirless toolkit but i don't know.
    thank you
    bye

  • How do I add in a MIDlet in a file like tis

    Hi all,
    Im very new to J2ME....I get an error on :
    Unable to create MIDlet EchoServer
    java.lang.InstantiationException: Class not a MIDlet
         at com.sun.midp.midlet.MIDletState.createMIDlet(+51)
         at com.sun.midp.midlet.Selector.run(+22)
    And here's my source code.....
    package javax.bluetooth;
    import javax.bluetooth.*;
    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;
    import javax.microedition.io.*;
    import java.io.*;
    public class EchoServer extends MIDlet implements CommandListener, Runnable
         StreamConnectionNotifier notifier;
         StreamConnection conn;
         LocalDevice localDevice;
         ServiceRecord serviceRecord;
         InputStream input;
         OutputStream output;
         private Form serForm;
         private Command exitCommand = new Command("Exit", Command.EXIT, 1);
         private Display display;
         private boolean isInit;
         private static String serverUrl = "btspp://localhost:" + BluetoothEchoDemo.RFCOMM_UUID + ";name=rfcommtest;authorize=true";
         public EchoServer()
              display = Display.getDisplay(this);
              serForm = new Form("Server1");
              serForm.addCommand(exitCommand);
              serForm.setCommandListener(this);
              serForm.append(new StringItem(null, "\n\nServer Running..."));
         isInit = false;
         Thread thread = new Thread(this);
         thread.start();
         public void displayForm()
              display.setCurrent(serForm);
         public void startApp()
              displayForm();
         public void destroyApp(boolean unconditional){}
         public void pauseApp(){}
         public void commandAction(Command c, Displayable s)
              notifyDestroyed();
         public void run()
         if (!isInit)
              // Initialization is done in the thread to avoid dead lock 'isInit' ensures it is done once only
              try
              conn = null;
              localDevice = LocalDevice.getLocalDevice();
              localDevice.setDiscoverable( DiscoveryAgent.GIAC );
              notifier = (StreamConnectionNotifier)Connector.open(serverUrl);
              catch (BluetoothStateException e)
              System.err.println( "BluetoothStateException: " + e.getMessage() );
              catch (IOException e)
              System.err.println( "IOException: " + e.getMessage() );
              isInit=true;
              System.out.println( "Starting Echo Server" );
         try
              System.out.println("\n\nServer Running...");
              // Pauses thread until Transmission occurs
              conn = notifier.acceptAndOpen();
              // Read Data Transmission
              String msg = BluetoothEchoDemo.readData(conn);
              System.out.println("Received Message from Client: " + msg);
              // Send Back a Message
              msg = "Hello Back from Server";
              output = conn.openOutputStream();
              output.write(msg.length()); // length is 1 byte
              output.write(msg.getBytes());
              output.close();
         catch (Exception ex)
              System.err.println("Bluetooth Server Running Error: " + ex);
    }

    Hi,
    http://java.sun.com/j2se/1.3/docs/tooldocs/win32/jar.html
    http://bobcat.webappcabaret.net/javachina/faq/jar.htm
    L.P.

Maybe you are looking for

  • LaserJet Pro MFP M276nw software installer not detecting printer via USB or wi-fi - Windows 7

    I am trying to install a LaserJet Pro MFP M276nw on Windows 7 Home Premium x64, and I know the printer functions fine, as I have installed it on both Windows Vista Basic x32 and Windows 7 Professional x64 all on the same desktop. The operating system

  • When i am backing up my iPhone, where is it backing up to?

    I am trying to bck up my iphone 3GS 16GB onto my Macbook Pro, but i dont know where it is backing it up to? Therefore i am worried i will not be able to access my data when i upgrade my phone. Anyon please help.

  • Can't see from one mac to another (Itunes)

    When i launch my front row on my macbook it informs me that there are no videos being shared on my mini. But when i review the mini inside itunes i clearly see all the content and can play it. Any ideas why itunes and front row would not work togethe

  • Stop direct execution of JSPs

    Hi, Is it possible to stop the user from deirectly executing a jsp file by typing the url in browser. I want to use the jsp only as a include file in other jsp pages. Thanks a lot, Chamal.

  • Complete Novice - Pease Help Re iplayer!

    Hello everyone :-) I used to be able to watch 4oD and the iplayer online but two days ago when I tried to play a programme it started jumping every 3 seconds and sometimes just not working at all. My inetenet is a bit slower than normal but I can sti