Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Aug 2010

    Unhappy Null pointer when load image.

    hai all, i have an error when i run my app in s60 emulator. the error is below:

    at Changcut.createImage(Unknown Source)
    at TestUI.initImages(Unknown Source)
    at TestUI.<init>(Unknown Source)
    at Changcut.<init>(Unknown Source)
    at java.lang.Class.newInstanceImpl(Native Method)
    at java.lang.Class.newInstance(Unknown Source)
    at com.symbian.j2me.midp.runtimeV2.Application.constructAction(Application.java:484)
    at com.symbian.j2me.midp.runtimeV2.Application.startRequest(Application.java:429)
    at com.symbian.j2me.midp.runtimeV2.Application.event(Application.java:298)
    at com.symbian.j2me.midp.runtimeV2.ApplicationEvent.dispatch(ApplicationEvent.java:90)
    at com.symbian.j2me.midp.runtimeV2.ApplicationThread.run(ApplicationThread.java:30)

    i don't know what cause it. can you help me tosolve my problem??.
    here is my code snippet that error occured.

    private void initImages()
    System.out.println("Initialize init image");
    imgSplash = Changcut.createImage("/screen-menu(320x240).png");
    System.out.println("imgSplash "+imgSplash);

    imgDino = Changcut.createImage("/screen-menu(320x240).png");
    System.out.println("imgDino "+imgDino);
    sprite = new Sprite(imgSplash, 176, 208);

    imgWin = Changcut.createImage("/screen-win(320x240).png");
    System.out.println("imgWin "+imgWin);
    imgLose = Changcut.createImage("/screen-game-over(320x240).png");
    System.out.println("imgLose "+imgLose);

    imgLove = Changcut.createImage("/love.png");
    System.out.println("imgLove "+imgLove);
    // imgNot = Changcut.createImage("/not.png");
    imgCredit = Changcut.createImage("/screen-credits(320x240).png");
    System.out.println("imgCredit "+imgCredit);
    imgScore = Changcut.createImage("/screen-score(320x240).png");
    System.out.println("imgScore "+imgScore);
    catch (Exception e)
    // TODO: handle exception

    // imgBingkai = Changcut.createImage("/bingkai.png");
    // System.out.println("imgBingkai "+imgBingkai);

  2. #2
    Super Contributor
    Join Date
    Apr 2007

    Re: Null pointer when load image.

    first of all always place something within yoyr catch statement, printing stacktrace won't work with j2me so you might want to do something else (write to system.out or maybe onscreen?)...
    also have you tried placing the png's in the root src directory of your project and/or in the resources directory ?
    You also might want to do a search in this forum, this kind of problem is very very common and has been discussed (and solved) countless of times...
    Note: please don't send private questions to me, as I don't have time to provide private support. All such questions should be posted on public forums, where I and others can see and answer them.

  3. #3
    Super Contributor
    Join Date
    Mar 2008
    The Capital of INDIA

    Re: Null pointer when load image.

    Hey Welcome to the Forum Nokia Discussion Boards...

    Was the println statement System.out.println("Initialize init image"); was printed on the console?
    I believe that this must be getting printed..

    Now if the next println statement is not getting printed then you must be sure about the few things, like

    1.As Tiger discissed,
    2.did you put the all images/resources in the res folder if yes then dont forget to add the folder in case of the Netbeans IDE,
    3.Plz check the name of the all images typed in the code are exactly same as the imge inside the folder.
    4.Plz note that the name of the images are case sensitive and the extensions too.
    Thanks with Regards,

    R a j - The K e r n e l

    Join Delhi-NCR Nokia Developer's Community,

Similar Threads

  1. Null pointer exception
    By clydening in forum Mobile Java General
    Replies: 3
    Last Post: 2010-04-19, 08:42
  2. Null Pointer Exception!
    By Eric Ma in forum Mobile Java General
    Replies: 16
    Last Post: 2009-03-10, 10:51
  3. Null pointer problem{help}
    By pamelag in forum Symbian User Interface
    Replies: 2
    Last Post: 2008-10-14, 07:22
  4. Replies: 2
    Last Post: 2004-07-30, 12:31
  5. another Null pointer exception
    By kvchen1985 in forum Mobile Java Tools & SDKs
    Replies: 1
    Last Post: 2004-06-28, 15:33

Posting Permissions

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