Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 6 of 6

Thread: I have a NullPointerException error that I dont understand

  1. #1
    Junior Member
    Join Date
    Dec 2013
    Posts
    10
    My Mood
    Aggressive
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default I have a NullPointerException error that I dont understand

    I get an error that I cant seem to fix . I have a lot of code, so ask me for each individual class.

    Error:

    Exception in thread "Thread-3" java.lang.NullPointerException
    	at com.riddlekeys.src.gfx.SpriteSheet.crop3(SpriteSheet.java:29)
    	at com.riddlekeys.src.gfx.ImageManager.<init>(ImageManager.java:177)
    	at com.riddlekeys.src.Game.init(Game.java:173)
    	at com.riddlekeys.src.Game.run(Game.java:235)
    	at java.lang.Thread.run(Unknown Source)

    Thanks!

    Luke
    Last edited by LukeR; December 26th, 2013 at 06:10 PM. Reason: I failed xD


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: I have a NullPointerException error that I dont understand

    Exception in thread "Thread-3" java.lang.NullPointerException
    at com.riddlekeys.src.gfx.SpriteSheet.crop3(SpriteShe et.java:29)
    There is a variable with a null value on line 29. Look at line 29 in the your source and see what variable is null. Then backtrack in the code to see why that variable does not have a valid value.
    If you can not tell which variable it is, add a println just before line 29 and print out the values of all the variables on that line.
    If you don't understand my answer, don't ignore it, ask a question.

  3. The Following User Says Thank You to Norm For This Useful Post:

    LukeR (December 14th, 2013)

  4. #3
    Junior Member
    Join Date
    Dec 2013
    Posts
    10
    My Mood
    Aggressive
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: I have a NullPointerException error that I dont understand

    Exception in thread "Thread-3" java.lang.NullPointerException
    at com.riddlekeys.src.gfx.SpriteSheet.crop3(SpriteSheet.java:29)
    There is a variable with a null value on line 29. Look at line 29 in the your source and see what variable is null. Then backtrack in the code to see why that variable does not have a valid value.
    If you can not tell which variable it is, add a println just before line 29 and print out the values of all the variables on that line.
    Ok thanks, will try that. If it doesnt work I will get back to you.

    -Luke

    --- Update ---

    I tried it, but I cant seem to find what is causing it. Could I send you source some how?

    -Luke

  5. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: I have a NullPointerException error that I dont understand

    Post the code you added with the println() and the line with the error. Also post what the println() printed out.
    If you don't understand my answer, don't ignore it, ask a question.

  6. #5
    Junior Member
    Join Date
    Dec 2013
    Posts
    10
    My Mood
    Aggressive
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: I have a NullPointerException error that I dont understand

    Quote Originally Posted by Norm View Post
    Post the code you added with the println() and the line with the error. Also post what the println() printed out.
    I cant, because it is a class that only runs methods, and the variables are type BufferedImage.

    (What I mean by that is that it is the type: int, boolean ect. IE:
    public static BufferedImage exampleVariable;

  7. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: I have a NullPointerException error that I dont understand

    What do you expect anyone can do with that?
    What code is on line 29?
    What was printed out by the println you added?
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Dont understand the nullpointerexception
    By xxxDanxxx in forum What's Wrong With My Code?
    Replies: 5
    Last Post: July 9th, 2013, 06:09 AM
  2. My code has error when its run....I dont understand what's wrong of it.
    By jacky@~ in forum What's Wrong With My Code?
    Replies: 3
    Last Post: October 11th, 2011, 07:48 AM
  3. Dont quite understand how Scanner.nextLine() works
    By TP-Oreilly in forum Java Theory & Questions
    Replies: 14
    Last Post: September 21st, 2011, 05:27 PM
  4. I dont understand why this happens....
    By ashenwolf in forum What's Wrong With My Code?
    Replies: 4
    Last Post: May 10th, 2011, 09:31 PM
  5. Dont understand what to write.. :/
    By johnwalker in forum What's Wrong With My Code?
    Replies: 1
    Last Post: December 4th, 2010, 09:31 PM

Tags for this Thread