Closed Thread
Results 1 to 3 of 3

Thread: Timer NullPointException

  1. #1
    domestic's Avatar
    domestic is offline Learning Programmer
    Join Date
    Mar 2007
    Location
    SCOTLAND!
    Posts
    44
    Rep Power
    0

    Timer NullPointException

    Hey. Im building this J2ME app. Basically, its an alarm, but I got a problem.

    I set the alarm and everything and it works perfect, except that the timer never works and I don't know why.

    Code:
            long now = new Date().getTime();
            stringItem3 = new StringItem(alarmDate.toString(), null);
    
            System.out.println(alarmDate.getTime() - now);
    
            long amount = alarmDate.getTime() - now;
            alarmTimer.schedule(at, amount); //error here
            System.out.println("im here");
        }
    
        class Alarmer extends TimerTask {
    
            public void run() {
                System.out.println("i run");
            }
        }
    Everytime though, it reaches the alarmTimer.schedule and throws this error:

    Code:
    TRACE: <at java.lang.NullPointerException:   0>, Exception caught in Display class
    java.lang.NullPointerException:   0
            at VisualMIDlet.doAlarm(VisualMIDlet.java:510)
            at VisualMIDlet.commandAction(VisualMIDlet.java:189)
            at javax.microedition.lcdui.Display$ChameleonTunnel.callScreenListener(), bci=46
            at com.sun.midp.chameleon.layers.SoftButtonLayer.processCommand(), bci=74
            at com.sun.midp.chameleon.layers.SoftButtonLayer.soft1(), bci=37
            at com.sun.midp.chameleon.layers.SoftButtonLayer.softPress(), bci=29
            at com.sun.midp.chameleon.layers.SoftButtonLayer.pointerInput(), bci=142
            at com.sun.midp.chameleon.CWindow.pointerInput(), bci=76
            at javax.microedition.lcdui.Display$DisplayEventConsumerImpl.handlePointerEvent(), bci=19
            at com.sun.midp.lcdui.DisplayEventListener.process(), bci=296
            at com.sun.midp.events.EventQueue.run(), bci=179
            at java.lang.Thread.run(Thread.java:619)
    510 is the alarmTimer.schedule line. Any ideas? Please.
    .


    Programming Languages: Java, VB6, VB2005 (.NET2)
    Web Languages: HTML, CSS, JS

    Website: http://abdn.ac.uk/~u41am6

    Opportunity is missed by most people because it is dressed in overalls and looks like work.

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Location
    Advertising world
    Posts
    Many

     
  3. #2
    Join Date
    Jul 2009
    Location
    Santa Clarita, CA
    Posts
    2,111
    Blog Entries
    47
    Rep Power
    31

    Re: Timer NullPointException

    You don't show where you initialize the Alarmer object as the name "at", which seems to be the problem. If "at" is not initialized, or for some other reason is NULL, you'll get that exception.
    Wow I changed my sig!

  4. #3
    domestic's Avatar
    domestic is offline Learning Programmer
    Join Date
    Mar 2007
    Location
    SCOTLAND!
    Posts
    44
    Rep Power
    0

    Re: Timer NullPointException

    Woops. Forgot to initialise either timer... Dam. My bad! Cheers mate.
    .


    Programming Languages: Java, VB6, VB2005 (.NET2)
    Web Languages: HTML, CSS, JS

    Website: http://abdn.ac.uk/~u41am6

    Opportunity is missed by most people because it is dressed in overalls and looks like work.

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. How to add timer in SDL?
    By even821 in forum C and C++
    Replies: 3
    Last Post: 10-16-2011, 11:45 PM
  2. Timer
    By BramS in forum Pascal and Delphi
    Replies: 3
    Last Post: 01-17-2011, 09:49 PM
  3. First Timer
    By Hunter100 in forum C and C++
    Replies: 3
    Last Post: 02-07-2010, 07:10 AM
  4. Timer?
    By restin84 in forum C and C++
    Replies: 12
    Last Post: 03-20-2009, 11:25 AM
  5. How to use a timer?
    By mechslayer in forum Visual Basic Programming
    Replies: 10
    Last Post: 01-08-2009, 09:07 PM

Tags for this Thread

Bookmarks

Posting Permissions

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