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.

Similar Messages

  • Is anybody aware of javax.microedition.lcdui.ChoiceGroup.IaSLayout

    Hi all
    If anybody is aware of the class or interface javax.microedition.lcdui.ChoiceGroup$IaSLayout, Pls give a detail description of it.
    looking forward for the reply

    In my MIDlet I tried to extend this inner class as "class MyIaSLayout extends IaSLayout" and It works fine. but while obfuscating the jar file, a warning comes
    Warning: javax.microedition.lcdui.EChoiceGroup$EIaSLayout: can't find superclass
    or interface javax.microedition.lcdui.ChoiceGroup$IaSLayout
    Warning: there were 1 unresolved references to superclasses or interfaces.
    You may need to specify additional library jars (using '-libraryjars').
    Please tell me what option should I use with -keep to obfuscate it properly. Right now I am using the progaurd.jar as obfuscator.

  • 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

  • PDA Error:Unable to load class javax/microedition/lcdui/ItemCommandListner

    I am developing a small inventory application for a PDA.When i tested my application on Zier 31 PDA I am getting the above mentioned error.
    I download the midp4palm.zip and installed midp.prc on PDA. then the sample application runs on the PDA,
    But my application not runs properly instead of i am getting an error as shown above.
    My application uses midp2.1 profile and jsr75 but now i am not getting any error concernibg to that but getting a basic error as shown above.
    I think midp4palm supports the javax/microedition/lcdui/ItemCommandListner class?
    pls help me

    Thanks for reply.
    But I did dowloaded IBM's J9 and still i am getting the same problem.......
    is i ahve to do any configuration with IBM's J9.because when i removed Java H(midp.prc) from PDA i am getting an error No JVM installed like that.....it is nor recognising the J9?

  • 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

  • About javax.microedition.lcdui.Form class

    Hi friends
    just tell me about the Form class in J2me .
    my question is that is List control can be supported by the form class OR simply we use the MIDlet class in the program
    Just answer me..

    List implements the displayable interface so you just use mildet class and to display the list, use setCurrent() method.
    If this answer is not matching your requirement, then let me know.

  • 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)
    }

  • 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.io.ConnectionNotFoundException: TCP open" Exception

    Dear All,
    I get "javax.microedition.io.ConnectionNotFoundException: TCP open" exception in J2ME program written by netbean with WTK2.0.
    I found out the exception got when I submit the URL to internet address (e.g. www.yahoo.com or www.google.com).
    However, the exception does not exist when I submit the URL to the host in intranet (e.g. 10.X.X.X)
    Do anyone of you have similar problem and could teach me how to submit the URL without the exception to internet address.
    Regrads and Thanks,
    Kelvin

    Hmm, try starting the thread from outside the constructor.
      (new Thread(new Connection(ipDb.getNextRecord()))).start(); Probably not the best practice to start threads in constructors. Also, it's highly likely that the device will only do 1 single network connection at a time anyway, even if you use multiple threads. This will be why it locks up the app, because the one internal OS thread that handles all the network IO is blocked, none of the other connection threads can do anything.

  • Javax.microedition.io.ConnectionNotFoundException: TCP open

    i am running my application this connecting to my local servers's web pages but when i try to connect to other internet servers then i am getting following error plz help me in solving this problem.....
    javax.microedition.io.ConnectionNotFoundException: TCP open
    at com.sun.midp.io.j2me.socket.Protocol.connect(+99)
    at com.sun.midp.io.ConnectionBaseAdapter.openPrim(+52)
    at com.sun.midp.io.j2me.socket.Protocol.openPrim(+108)
    at com.sun.midp.io.ConnectionBaseAdapter.openPrim(+14)
    at com.sun.midp.io.ConnectionBaseAdapter.openPrim(+8)
    at com.sun.midp.io.j2me.http.Protocol.connect(+73)
    at com.sun.midp.io.j2me.http.Protocol.streamConnect(+57)
    at com.sun.midp.io.j2me.http.Protocol.startRequest(+12)
    at com.sun.midp.io.j2me.http.Protocol.sendRequest(+38)
    Uncaught exception java/lang/NullPointerException.
    at com.sun.midp.io.j2me.http.Protocol.sendRequest(+6)
    at com.sun.midp.io.j2me.http.Protocol.getResponseCode(+8)
    at QuoteRetriever.run(+43)

    s there any embeded database for j2me?RMS is the database for j2me.
    You can either use RMS or Files to store your application data. Please note Not all devices support File system access and files written by your application can also be seen by user while he explores the file system.
    RMS is supported by all MIDP devices. RMS data cannot be seen in file system. You can set access setting while creating the recordstore.
    As you have solved your problem, please mark this question as answered.
    Atul

  • Javax.microedition.io.ConnectionNotFoundException: socket open: failed

    I am deploying my java midlet application in several phones and few of them faces the following exception when I tried establishing a Socket connection:
    javax.microedition.io.ConnectionNotFoundException: socket open: failed
    Does anyone have any suggestion to this?
    Please help as this is urgent. Thanks you.

    I think your request is not reaching to the server, or reaching but server is not responding plz chk the server settings
    Regards
    @rjun

  • Javax.microedition.media.MediaException PLEASE HELP

    Hi
    I'm currently developing application for the new Motorola i860
    I'm writing a player that will be able to play wav/midi/amr/vselp ...
    Im trying to skip back and forward using Player.setMediaTime()
    When I upload the applicatiopn to the emolator (download from iden.motorola .com) its working great but when I upload the application to the phone I got exception :
    "javax.microedition.media.MediaException setMediaTime() is not set"
    Any one know why its working perfect on the Emolator and NOT WORKING ON THE REAL PHONE ????

    Hi,
    Please check if setMediaTime is supported in your device.

  • Javax.microedition.media.Mediaexception:Deviceerror

    I am working on nokia 3110 handset. I am trying make application to to record and play sound. I am successfully recording the sound but while playing recorded sound it is giving javax.microedition.media.Mediaexception:Deviceerror. The program is running fine on emulator. I am using content type as audio/x-wav.Could anybody suggest any way???? Code
    private void recordtofile()
    try{
    store = RecordStore.openRecordStore("voicestore",true);
    p= Manager.createPlayer("capture://audio");
    p.realize();
    rc = (RecordControl)p.getControl("RecordControl");
    output = new ByteArrayOutputStream();
    rc.setRecordStream(output);
    rc.startRecord();
    p.start();
    Thread.currentThread().sleep(10000);
    p.stop();
    rc.stopRecord();
    rc.commit();
    byte[] b = output.toByteArray();
    store.addRecord(b,0,b.length);
    InputStream is = new ByteArrayInputStream(b);
    player = Manager.createPlayer(is, "audio/x-wav");
    player.prefetch();
    player.start();
    mDisplay.setCurrent(mMainScreen);
    catch(Exception e)
    {showException(e);
    }

    Hi,
    Please check if setMediaTime is supported in your device.

  • UnsatisfiedLinkError: javax.microedition.media.Manager.initMMedia()

    Hello all,
    I'm trying to develop an application recording audio on J2ME. The trouble is that every time I'm calling Manager.createPlayer(anything) method I get the following on my terminal:
    Failed to find configuration object - DefaultConfiguration is used!
    Exception in thread "main" java.lang.UnsatisfiedLinkError: javax.microedition.media.Manager.initMMedia()V
         at javax.microedition.media.Manager.initMMedia(Native Method)
         at javax.microedition.media.Manager.<clinit>(Manager.java:490)
         at local.Temp.run2(Temp.java:65)I tried with
    Player p = Manager.createPlayer("capture://audio");and
    Player p = Manager.createPlayer("oak.wav");and even
    Player p = Manager.createPlayer(Manager.TONE_DEVICE_LOCATOR); each and every time the execution stops on the line where createPlayer method is called. I'm running Eclipse version 3.3.2 with EclipseME 1.7.9 and Sun Java Wireless Toolkit for CLDC v 2.5.
    I am quite clueless currently so I would really appreciate a hint explaining what the error may mean.
    Thanks a lot,
    Simon
    ...and BTW: another think I dont get is that each time the exception is thrown the execution stops in spite of the fact, that createPlayer method is in try/catch block with catch catching every Exception (catch (Exception e) ), but that is just a curiosity question.

    Ok, first thing : you MUST NOT use a full system path for a ressource. Create a directory in your netbean project (rsc for instance) and do sthg like :
    player = Manager.createPlayer("/rsc/film.mpg");Second thing, to get supported formats, use :
    String protocols[] = Manager.getSupportedProtocols();
    for (int i=0;i<protocols.length;i++) {
      String contentTypes[] = Manager.getSupportedContentTypes(protocols);
    // Display all strings in the array ....

  • Package javax.microedition.sip

    Hello,
    I am trying to develope a sip client using J2ME with the package javax.microedition.sip. This client should communicate with a Trixbox virtual machine (an Asterisk implementation). I am using NetBeans 5.5.1 with Mobility Pack and phone emulator. I also tried NetBeans 6.
    Has anybody ever used the microedition.sip package for communicating with an Asterisk PBX server?
    I can't get responses to my sip requests, except when I try to send a request with an inexistent user ID and get a 404 (Not Found) error. Here is a portion of my java midlet:
    scn = (SipConnectionNotifier) Connector.open("sip:5060");
    // build the contact URI
    String realm;
    String contact =
              new String("sip:101@"+scn.getLocalAddress()+":"+scn.getLocalPort());
    // open client connection to the SIP registrar in this case "host.com"     
    sc = (SipClientConnection) Connector.open("sip:172.17.25.110");
    // initialize REGISTER with appropriate headers
    sc.initRequest("REGISTER", scn);
    sc.setHeader("From", "sip:[email protected]");
    sc.setHeader("To", "sip:[email protected]");
    sc.setHeader("Contact", contact);
    sc.send();
    boolean handled = false;
    int scode = 0;
    while(!handled) {
         SipHeader sh;
         // wait max 30 secs for response
         sc.receive(30000);
         scode = sc.getStatusCode();
         switch(scode)
    case 401:
    sh = new SipHeader("WWW-Authenticate",
    sc.getHeader("WWW-Authenticate"));
    realm = sh.getParameter("realm");
    // here for example, prompt user for password for this realm
    // set credentials to initiate re-REGISTER
    sc.setCredentials("101", "101", realm);
    break;
    case 407:
    sh = new SipHeader("Proxy-Authenticate",
    sc.getHeader("Proxy-Authenticate"));
    realm = sh.getParameter("realm");
    // here for example, prompt user for password for this realm
    // set credentials to initiate re-REGISTER
    sc.setCredentials("101", "101", realm);
    break;
    case 200:
    // handle OK response
    handled = true;
    break;
    default:
    // handle other responses
    handled = true;
    sc.close();
    Can anybody help me please?

    I have the same problem with u, I have project how to implement VoIP SIP mobile using j2me with server asterisk. but how to the registration client to asterisk server? hee....m. The capturing audio will be sent with RTP, I can't that

Maybe you are looking for

  • Can I create a new itunes account and synch my iPod to it?

    I have an iTunes account, but have only bought music and apps on it for my son's iPod Touch. Now I have my own iPod Touch and we want to have separate accounts. I already synched my new iPod to my own account - the one where all his music is. What ca

  • Adobe Camera Raw in Elements 11

    I'm using Windows 8.1. In Elements 11 I updated Camera Raw, but although it has confirmed the update, I cannot find it in Elements. Help please

  • Loyalty Management - Redemption Process

    Dear Experts, I'm a bit confused with the Loyalty Management redemption process with Partnership. Would appreciate if you could clear my thoughts. We have this process where currently, when a customer buys a product from a retail partner, the custome

  • How can i show ringtone in my itune

    why is the ringtone is missing in the catergory from itune

  • IPhone 3G & New Notebook

    Hey everyone. I've got a question that I see has been asked many many times by others, and I'm sorry to repost the question. In the past, people who have asked about this issue were mostly interested in finding out how music can be transferred off th