×

Discussion Board

Results 1 to 10 of 10
  1. #1
    Registered User
    Join Date
    Mar 2008
    Posts
    7

    Lightbulb My browser works on simulator but not on mobile

    My browser works on simulator...but when I run it on mobile it gives NullPointerException
    when i run it on simulator it executes but gives following exceptionss

    java.lang.NullPonterException at

    jec.MapCanvas.paint(+193) ////One of the classes in my browser
    javax.microedition.lcdui.Display.repaint(+82)
    javax.microedition.lcdui.retisterNewCurrent(+235)
    javax.microedition.lcdui.Display$access(+6)
    javax.microedition.lcdui.Display$DisplayAccessor.foregroundNotify(+46)
    javax.microedition.lcdui.Display$DisplayManagerImpl.notifyWantsForeground(+152)
    javax.microedition.lcdui.Display$Display.access$100(+6)
    javax.microedition.lcdui.Display.setCurrent(+70)
    javax.microedition.midlet.MidletProxy.startApp(+7)
    com.sun.midp.midlet.Scheduler.schedule(+270)
    com.sun.midp.main.Main.runLocalClass(+28)
    com.sun.midp.main.Main.main(+80)
    jec.jecbrowser.startApp(+528) //////This my browser's midlet

  2. #2
    Nokia Developer Champion
    Join Date
    Apr 2003
    Location
    USA, CA
    Posts
    7,192

    Re: My browser works on simulator but not on mobile

    Which phone are you running this on?

    What is the MIDlet doing during the application startup?

    Hartti

  3. #3
    Registered User
    Join Date
    Mar 2008
    Posts
    7

    Post Re: My browser works on simulator but not on mobile

    My project includes 29 classes...
    This is my midlet's source code

    package jec;

    import javax.microedition.io.Connector;
    import javax.microedition.io.HttpConnection;
    import javax.microedition.lcdui.*;
    import javax.microedition.midlet.MIDlet;

    public class jecbrowser extends MIDlet
    implements CommandListener {

    public static Display display;
    public static MapCanvas mc;
    public static String encoding = "UTF-8";
    public static String pageurl = "http://wap.mtv.com";
    public static String helpurl = "http://mobile.google.com";
    Command C4;
    Command C5;
    Command C6;
    List C7;
    Command C8;
    Form C9;
    Command CA;
    Command CB;
    Command CC;
    Command CD;
    Command CE;
    TextField tf;
    List CF;
    int D0;
    Object D1;
    Command D2;
    Command D3;
    Command D4;
    KbdTextBox D5;
    TextBox tb;
    List D6;
    String D8;
    String D9;
    public static CachePool cachepool;
    int DA;
    Bookmarks _fld0128;

    public jecbrowser() {
    }

    public void startApp() {
    if (mc != null) {
    MapCanvas _tmp = mc;
    MapCanvas.still = false;
    display.setCurrent(mc);
    return;
    }
    String s = getAppProperty("jecbrowser-Encoding");
    if (s != null) {
    s = s.trim();
    if (s.length() > 0) {
    encoding = s.trim();
    }
    }
    D8 = getAppProperty("jecbrowser-Home");
    if (D8 != null) {
    D8 = D8.trim();
    if (D8.length() > 0) {
    pageurl = D8;
    } else {
    D8 = pageurl;
    }
    } else {
    D8 = pageurl;
    }
    D9 = D8;
    try {
    DA = Integer.parseInt(getAppProperty("jecbrowser-Cache"));
    }
    catch (Exception exception) {
    DA = 16384;
    }
    cachepool = new CachePool(DA);
    _fld0128 = new Bookmarks();
    C4 = new Command("START", 1, 1);
    C5 = new Command("GO", 1, 1);
    D2 = new Command("SET", 1, 1);
    C6 = new Command("MENU", 1, 2);
    C8 = new Command("SET", 1, 1);
    D3 = new Command("EDIT", 1, 2);
    D4 = new Command("OK", 1, 1);
    CA = new Command("GO", 1, 1);
    CB = new Command("DEL", 1, 2);
    CC = new Command("ADD", 1, 1);
    CD = new Command("EDIT", 1, 2);
    CE = new Command("OK", 1, 1);
    C7 = new List("MENU", 3, new String[]{
    "Back", "Home", "Online Help", "Enter URL", "Bookmarks", "Add Bookmark", "Save Cache", "Reset Cache", "Return", "Exit jecbrowser"
    }, null);
    C7.addCommand(C8);
    C7.setCommandListener(this);
    mc = new MapCanvas();
    mc.addCommand(C4);
    mc.addCommand(C6);
    mc.setCommandListener(this);
    mc.init();
    try {
    HttpConnection httpconnection = (HttpConnection) Connector.open(pageurl);
    httpconnection.close();
    }
    catch (Exception exception1) {
    }
    display = Display.getDisplay(this);
    display.setCurrent(mc);
    }

  4. #4
    Registered User
    Join Date
    Mar 2008
    Posts
    7

    Post Re: My browser works on simulator but not on mobile

    public void commandAction(Command command, Displayable displayable) {
    if (command == CA) {
    int i = CF.getSelectedIndex();
    CF = null;
    Bookmarks _tmp = _fld0128;
    String s2 = Tools.GetToken((String) Bookmarks.BM.elementAt(i), 2);
    Tools.pushHistoryStack(pageurl);
    pageurl = s2;
    MapCanvas _tmp1 = mc;
    MapCanvas.delayload = true;
    MapCanvas _tmp2 = mc;
    MapCanvas.BaseY = 0;
    MapCanvas _tmp3 = mc;
    MapCanvas.still = false;
    display.setCurrent(mc);
    return;
    }
    if (command == CB) {
    int j = CF.getSelectedIndex();
    CF = null;
    Bookmarks _tmp4 = _fld0128;
    Bookmarks.BM.removeElementAt(j);
    _fld0128.save();
    MapCanvas _tmp5 = mc;
    MapCanvas.still = false;
    display.setCurrent(mc);
    return;
    }
    if (command == CD) {
    D5 = new KbdTextBox(tf.getString());
    D5.addCommand(CE);
    D5.setCommandListener(this);
    MapCanvas _tmp6 = mc;
    MapCanvas.still = true;
    display.setCurrent(D5);
    return;
    }
    if (command == CE) {
    tf.setString(D5.getString());
    D5 = null;
    MapCanvas _tmp7 = mc;
    MapCanvas.still = true;
    display.setCurrent(C9);
    return;
    }
    if (command == CC) {
    String s = tf.getString();
    if (s == null || s.trim().length() == 0) {
    s = "bookmark";
    }
    Bookmarks _tmp8 = _fld0128;
    Bookmarks.BM.addElement(s + "@" + pageurl);
    _fld0128.save();
    tf = null;
    C9 = null;
    MapCanvas _tmp9 = mc;
    MapCanvas.still = false;
    display.setCurrent(mc);
    return;
    }
    if (command == D3) {
    D5 = new KbdTextBox(tb.getString());
    if ((tb.getConstraints() & 0x10000) != 0) {
    D5.setPassword(true);
    }
    D5.addCommand(D4);
    D5.setCommandListener(this);
    MapCanvas _tmp10 = mc;
    MapCanvas.still = true;
    display.setCurrent(D5);
    return;
    }
    if (command == D4) {
    tb.setString(D5.getString());
    D5 = null;
    MapCanvas _tmp11 = mc;
    MapCanvas.still = true;
    display.setCurrent(tb);
    return;
    }
    if (command == C6) {
    MapCanvas _tmp12 = mc;
    MapCanvas.still = true;
    display.setCurrent(C7);
    return;
    }
    if (command == C8) {
    int k = C7.getSelectedIndex();
    if (k == 0) {
    MapCanvas _tmp13 = mc;
    if (MapCanvas.mode != 0) {
    String s3 = Tools.popHistoryStack();
    pageurl = s3;
    MapCanvas _tmp14 = mc;
    MapCanvas.delayload = true;
    MapCanvas _tmp15 = mc;
    MapCanvas.BaseY = 0;
    MapCanvas _tmp16 = mc;
    MapCanvas.still = false;
    display.setCurrent(mc);
    }
    }
    if (k == 1) {
    Tools.pushHistoryStack(pageurl);
    pageurl = D8;
    MapCanvas _tmp17 = mc;
    MapCanvas.delayload = true;
    MapCanvas _tmp18 = mc;
    MapCanvas.BaseY = 0;
    MapCanvas _tmp19 = mc;
    MapCanvas.still = false;
    display.setCurrent(mc);
    }
    if (k == 2) {
    Tools.pushHistoryStack(pageurl);
    pageurl = helpurl;
    MapCanvas _tmp20 = mc;
    MapCanvas.delayload = true;
    MapCanvas _tmp21 = mc;
    MapCanvas.BaseY = 0;
    MapCanvas _tmp22 = mc;
    MapCanvas.still = false;
    display.setCurrent(mc);
    }
    if (k == 3) {
    D0 = 0;
    tb = new TextBox("", "", 128, 0);
    tb.setString(D9);
    tb.addCommand(D3);
    tb.addCommand(D2);
    tb.setCommandListener(this);
    MapCanvas _tmp23 = mc;
    MapCanvas.still = true;
    display.setCurrent(tb);
    }
    if (k == 4) {
    Bookmarks _tmp24 = _fld0128;
    int l = Bookmarks.BM.size();
    if (l == 0) {
    return;
    }
    String as[] = new String[l];
    for (int j1 = 0; j1 < l; j1++) {
    as[j1] = Tools.GetToken((String) Bookmarks.BM.elementAt(j1), 1);
    }

    CF = new List("Bookmarks", 3, as, null);
    CF.addCommand(CA);
    CF.addCommand(CB);
    CF.setCommandListener(this);
    MapCanvas _tmp25 = mc;
    MapCanvas.still = true;
    display.setCurrent(CF);
    }
    if (k == 5) {
    tf = new TextField("Description:", "", 128, 0);
    C9 = new Form("Add Bookmark");
    C9.append(tf);
    C9.addCommand(CC);
    C9.addCommand(CD);
    C9.setCommandListener(this);
    MapCanvas _tmp26 = mc;
    MapCanvas.still = true;
    display.setCurrent(C9);
    }
    if (k == 6) {
    cachepool.saveCache();
    }
    if (k == 7) {
    cachepool.reset();
    }
    if (k == 8) {
    MapCanvas _tmp27 = mc;
    MapCanvas.still = false;
    display.setCurrent(mc);
    }
    if (k == 9) {
    notifyDestroyed();
    }
    return;
    }

  5. #5
    Registered User
    Join Date
    Mar 2008
    Posts
    7

    Post Re: My browser works on simulator but not on mobile

    if (command == C4) {
    mc.removeCommand(C4);
    mc.addCommand(C5);
    mc.addCommand(C6);
    MapCanvas _tmp28 = mc;
    MapCanvas.LogoImage = null;
    Tools.initHistoryStack();
    Tools.pushHistoryStack(pageurl);
    HTMLStream htmlstream = new HTMLStream(pageurl);
    htmlstream = null;
    MapCanvas _tmp29 = mc;
    MapCanvas.mode = 1;
    MapCanvas _tmp30 = mc;
    MapCanvas.BaseY = 0;
    mc.repaint();
    return;
    }
    if (command == D2) {
    switch (D0) {
    default:
    break;

    case 0: // '\0'
    MapCanvas _tmp31 = mc;
    if (MapCanvas.mode == 0) {
    pageurl = tb.getString();
    MapCanvas _tmp32 = mc;
    MapCanvas.still = false;
    display.setCurrent(mc);
    } else {
    String s1 = tb.getString();
    Tools.pushHistoryStack(pageurl);
    pageurl = s1;
    MapCanvas _tmp33 = mc;
    MapCanvas.delayload = true;
    MapCanvas _tmp34 = mc;
    MapCanvas.BaseY = 0;
    MapCanvas _tmp35 = mc;
    MapCanvas.still = false;
    display.setCurrent(mc);
    }
    D9 = pageurl;
    tb = null;
    break;

    case 1: // '\001'
    TextObj textobj = (TextObj) D1;
    textobj.value = tb.getString();
    textobj.paint(MapCanvas.VG);
    D1 = null;
    tb = null;
    MapCanvas _tmp36 = mc;
    MapCanvas.still = false;
    display.setCurrent(mc);
    break;

    case 2: // '\002'
    SelectObj selectobj = (SelectObj) D1;
    selectobj.setOption(D6.getSelectedIndex());
    selectobj.paint(MapCanvas.VG);
    D1 = null;
    D6 = null;
    MapCanvas _tmp37 = mc;
    MapCanvas.still = false;
    display.setCurrent(mc);
    break;
    }
    }
    if (command == C5) {
    if (HTMLStream.hsvector.size() > 0) {
    HotSpot hotspot = (HotSpot) HTMLStream.hsvector.elementAt(HTMLStream.hsindex);
    D0 = hotspot.type;
    switch (D0) {
    default:
    break;

    case 0: // '\0'
    String s4 = (String) hotspot.obj;
    Tools.pushHistoryStack(pageurl);
    pageurl = s4;
    HTMLStream htmlstream1 = new HTMLStream(pageurl);
    htmlstream1 = null;
    MapCanvas _tmp38 = mc;
    MapCanvas.BaseY = 0;
    mc.repaint();
    break;

    case 1: // '\001'
    TextObj textobj1 = (TextObj) hotspot.obj;
    D1 = textobj1;
    if (textobj1.password) {
    tb = new TextBox("", "", 128, 0x10000);
    } else {
    tb = new TextBox("", "", 128, 0);
    }
    tb.setString(textobj1.value);
    tb.addCommand(D3);
    tb.addCommand(D2);
    tb.setCommandListener(this);
    MapCanvas _tmp39 = mc;
    MapCanvas.still = true;
    display.setCurrent(tb);
    break;

    case 2: // '\002'
    SelectObj selectobj1 = (SelectObj) hotspot.obj;
    D1 = selectobj1;
    D6 = new List("Select", 3);
    for (int i1 = 0; i1 < selectobj1.ov.size(); i1++) {
    OptionObj optionobj = (OptionObj) selectobj1.ov.elementAt(i1);
    D6.append(optionobj.value, null);
    }

    D6.setSelectedIndex(selectobj1.index, true);
    D6.addCommand(D2);
    D6.setCommandListener(this);
    MapCanvas _tmp40 = mc;
    MapCanvas.still = true;
    display.setCurrent(D6);
    break;

    case 3: // '\003'
    ButtonObj buttonobj = (ButtonObj) hotspot.obj;
    if (buttonobj.formid < 0 || buttonobj.formid >= HTMLStream.formvector.size()) {
    break;
    }
    FormObj formobj = (FormObj) HTMLStream.formvector.elementAt(buttonobj.formid);
    if (buttonobj.type.equals("reset")) {
    formobj.reset();
    } else {
    Tools.pushHistoryStack(pageurl);
    formobj.go();
    }
    mc.repaint();
    break;

    case 4: // '\004'
    ChoiceObj choiceobj = (ChoiceObj) hotspot.obj;
    if (choiceobj.flag) {
    choiceobj.flag = false;
    } else {
    choiceobj.flag = true;
    }
    choiceobj.paint(MapCanvas.VG);
    mc.repaint();
    break;
    }
    }
    return;
    } else {
    return;
    }
    }

    public void pauseApp() {
    MapCanvas _tmp = mc;
    MapCanvas.still = true;
    }

    public void destroyApp(boolean flag) {
    }

    }



    //Plz help me out if u can

  6. #6
    Registered User
    Join Date
    Mar 2008
    Posts
    7

    Lightbulb Re: My browser works on simulator but not on mobile

    I have tried it on Nokia 3310 and some other viersions of Nokia

    The source code is in the order #3-#4-#5

  7. #7
    Nokia Developer Champion
    Join Date
    Apr 2003
    Location
    USA, CA
    Posts
    7,192

    Re: My browser works on simulator but not on mobile

    Quite impossible to read.

    My quick guess is that some exception is thrown in the startApp before the mc is created. in the catch clause you are then referring to mc.

    But just a guess... You need to debug more.

    Hartti

  8. #8
    Registered User
    Join Date
    Mar 2008
    Posts
    7

    Lightbulb Re: My browser works on simulator but not on mobile

    hey my browser runs on sony ericson mobiles....but not on Nokia mobile.....On nokia mobiles it gives the error of NullPointerException........
    Some experts told me that Nokia considers some class libraries as case sensistive but sony ericson doesnt.....so what should i do now so that my browser runs on nokia too

  9. #9
    Nokia Developer Champion
    Join Date
    Apr 2003
    Location
    USA, CA
    Posts
    7,192

    Re: My browser works on simulator but not on mobile

    Just guessing. Do you have a method named "update" in your MapCanvas class. Try to rename that.
    http://wiki.forum.nokia.com/index.ph...d_update%28%29

    Java is case sensitive. SE devices should follow that too.

    Hartti

  10. #10
    Registered User
    Join Date
    Mar 2008
    Posts
    7

    Re: My browser works on simulator but not on mobile

    Can i upload my project here...
    If yes then how

    experts on some other sites told me that...
    the Class.getResourceAsStream is case sensitive for Nokia
    Last edited by gaurav_varma; 2008-04-07 at 18:41.

Similar Threads

  1. Can Nokia6600 mobile browser use function of proxy ?=.=
    By mikeliu1976 in forum Browsing and Mark-ups
    Replies: 0
    Last Post: 2005-03-14, 06:50
  2. Replies: 1
    Last Post: 2005-03-10, 11:59
  3. How does mobile browser interact with users?..@@.
    By mikeliu1976 in forum Browsing and Mark-ups
    Replies: 0
    Last Post: 2005-02-27, 14:34
  4. Viewing a wml file using Nokia Mobile Browser 4.0
    By axmug in forum Mobile Web Site Development
    Replies: 0
    Last Post: 2004-07-21, 15:39
  5. Nokia Mobile VPN Client
    By marcyl in forum Symbian Networking & Messaging (Closed)
    Replies: 1
    Last Post: 2003-12-01, 14:47

Posting Permissions

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